diff --git a/src/js/lightbox.js b/src/js/lightbox.js
index <HASH>..<HASH> 100644
--- a/src/js/lightbox.js
+++ b/src/js/lightbox.js
@@ -302,7 +302,7 @@
         if (self.options.maxWidth && self.options.maxWidth < maxImageWidth) {
           maxImageWidth = self.options.maxWidth;
         }
-        if (self.options.maxHeight && self.options.maxHeight < maxImageWidth) {
+        if (self.options.maxHeight && self.options.maxHeight < maxImageHeight) {
           maxImageHeight = self.options.maxHeight;
         }
Bugfix - MaxHeight wouldn't work.

Seems like there is a bug in line <I>, the code is comparing against width but we want height.