lokesh / lightbox2

THE original Lightbox script (v2).
http://lokeshdhakar.com/projects/lightbox2/
MIT License
6.22k stars 1.77k forks source link

maxWidth and maxHeight are useless if they don't preserve aspect ratio #528

Closed teo1978 closed 7 years ago

teo1978 commented 8 years ago

From the docs:

maxWidth: If set, the image height will be limited to this number, in pixels. Aspect ratio will not be maintained. maxHeight: If set, the image width will be limited to this number, in pixels. Aspect ratio will not be maintained.

The fact that the aspect ratio will not be maintained renders these options completely useless. There are use cases for these options: one may want the image size to never exceed some given measures; however nobody in their right mind would accept to alter the aspect ratio in these cases.

So, if you want these options to be of any use, you shoud make them preserve aspect ratio. If you really want to also support the ability to force a max width and/or height loosing the aspect ratio, then add a maintainAspectRatio (or something) parameter which would be true by default.

lokesh commented 7 years ago

This was actually a case of flawed documentation. The aspect ratio is maintained if one of the max options is set. I've updated the options description as well as added a comment in the source javascript for clarity. Thanks for catching.

http://lokeshdhakar.com/projects/lightbox2/#options https://github.com/lokesh/lightbox2/blob/master/src/js/lightbox.js#L307