From 5550b1f14b2feb5cb9fe47946ef7d3358ce3ff40 Mon Sep 17 00:00:00 2001 From: Greg Barker Date: Thu, 10 Apr 2014 18:30:20 -0700 Subject: [PATCH] Added support for enforcing min-width & min-height on lightbox images --- js/bootstrap-lightbox.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/js/bootstrap-lightbox.js b/js/bootstrap-lightbox.js index da2282c..e8d5df1 100644 --- a/js/bootstrap-lightbox.js +++ b/js/bootstrap-lightbox.js @@ -233,6 +233,25 @@ //$image.height = preloader.height; //return _this.sizeContainer(preloader.width, preloader.height); + var minWidth = parseInt($image.css('min-width'), 10); + var minHeight = parseInt($image.css('min-height'), 10); + + if (preloader.width < minWidth) + { + originalWidth = preloader.width; + originalHeight = preloader.height; + preloader.width = minWidth; + preloader.height = originalHeight / originalWidth * preloader.width; + } + + if (preloader.height < minHeight) + { + originalWidth = preloader.width; + originalHeight = preloader.height; + preloader.height = minHeight; + preloader.width = originalWidth / originalHeight * preloader.height; + } + // The image could be bigger than the window, that is an issue. if( (preloader.width + padLeft + padRight) >= windowWidth) {