|
327 | 327 | maxImageHeight = self.options.maxHeight; |
328 | 328 | } |
329 | 329 |
|
330 | | - // Is the current image's width or height is greater than the maxImageWidth or maxImageHeight |
331 | | - // option than we need to size down while maintaining the aspect ratio. |
332 | | - if ((preloader.width > maxImageWidth) || (preloader.height > maxImageHeight)) { |
333 | | - if ((preloader.width / maxImageWidth) > (preloader.height / maxImageHeight)) { |
334 | | - imageWidth = maxImageWidth; |
335 | | - imageHeight = parseInt(preloader.height / (preloader.width / imageWidth), 10); |
336 | | - $image.width(imageWidth); |
337 | | - $image.height(imageHeight); |
338 | | - } else { |
339 | | - imageHeight = maxImageHeight; |
340 | | - imageWidth = parseInt(preloader.width / (preloader.height / imageHeight), 10); |
341 | | - $image.width(imageWidth); |
342 | | - $image.height(imageHeight); |
343 | | - } |
| 330 | + } else { |
| 331 | + maxImageWidth = self.options.maxWidth || preloader.width || maxImageWidth; |
| 332 | + maxImageHeight = self.options.maxHeight || preloader.height || maxImageHeight; |
| 333 | + } |
| 334 | + |
| 335 | + // Is the current image's width or height is greater than the maxImageWidth or maxImageHeight |
| 336 | + // option than we need to size down while maintaining the aspect ratio. |
| 337 | + if ((preloader.width > maxImageWidth) || (preloader.height > maxImageHeight)) { |
| 338 | + if ((preloader.width / maxImageWidth) > (preloader.height / maxImageHeight)) { |
| 339 | + imageWidth = maxImageWidth; |
| 340 | + imageHeight = parseInt(preloader.height / (preloader.width / imageWidth), 10); |
| 341 | + $image.width(imageWidth); |
| 342 | + $image.height(imageHeight); |
| 343 | + } else { |
| 344 | + imageHeight = maxImageHeight; |
| 345 | + imageWidth = parseInt(preloader.width / (preloader.height / imageHeight), 10); |
| 346 | + $image.width(imageWidth); |
| 347 | + $image.height(imageHeight); |
344 | 348 | } |
345 | 349 | } |
346 | 350 | self.sizeContainer($image.width(), $image.height()); |
|
0 commit comments