FIX: lightbox images only if bigger than max_image_width/height

FIX: lightbox images only if bigger than max_image_width/height

diff --git a/assets/javascripts/discourse/initializers/hook-decrypt-post.js.es6 b/assets/javascripts/discourse/initializers/hook-decrypt-post.js.es6
index 0a20ab4..6b12778 100644
--- a/assets/javascripts/discourse/initializers/hook-decrypt-post.js.es6
+++ b/assets/javascripts/discourse/initializers/hook-decrypt-post.js.es6
@@ -232,11 +232,16 @@ function postProcessPost(siteSettings, topicId, $post) {
     .find(".cooked img")
     .not($(".d-lazyload-hidden"))
     .each(function() {
-      $(this).wrap(
-        '<div class="lightbox-wrapper"><a class="lightbox" href="' +
-          $(this).attr("src") +
-          '"</a></div>'
-      );
+      if (
+        this.naturalWidth > siteSettings.max_image_width ||
+        this.naturalHeight > siteSettings.max_image_height
+      ) {
+        $(this).wrap(
+          '<div class="lightbox-wrapper"><a class="lightbox" href="' +
+            $(this).attr("src") +
+            '"</a></div>'
+        );
+      }
     });
   lightbox($post[0], siteSettings);
 

GitHub sha: 59014cb0