ashleydw / lightbox

A lightbox gallery plugin for Bootstrap
http://ashleydw.github.io/lightbox
MIT License
1.85k stars 1.3k forks source link

Add max-width/height options #273

Open RafaPolit opened 6 years ago

RafaPolit commented 6 years ago

I am showcasing images optimized for retina displays (@2x) which are 2400px width, forced to display at 1200px.

When I refernce those images inside lightbox, setting the "width" option to a size SMALLER than the image file has no effect. It only works for EXPANDING original image files, but larger files are not scaled down.

What I really would want is to have a 'max-width/max-height' option that will allow for the modal to be as small as needed and grow no further than XXX pixels, to keep image display to its best.

Thanks, Rafa.

ashleydw commented 6 years ago

Sounds like adding two new data-* attributes is the best thing to do, and then in the _resize method check that the attribute value is < maxHeight and width and use which ever is most appropriate.

RafaPolit commented 6 years ago

Yeap, I have implemented that approach in a pull request (with added options in the example HTML file), and also improving a bit some padding / aspect ratio issues.