FIX: decorate decrypted images with lightbox (#17)

FIX: decorate decrypted images with lightbox (#17)

For classic posts, when we generate cooked version we wrap images with lightbox classes

https://github.com/discourse/discourse/blob/master/lib/cooked_post_processor.rb#L416

However, for encrypted message we don’t have cooked version so we need to wrap images after successful decryption.

diff --git a/assets/javascripts/discourse/initializers/hook-decrypt-post.js.es6 b/assets/javascripts/discourse/initializers/hook-decrypt-post.js.es6
index 58f1100..0a20ab4 100644
--- a/assets/javascripts/discourse/initializers/hook-decrypt-post.js.es6
+++ b/assets/javascripts/discourse/initializers/hook-decrypt-post.js.es6
@@ -11,6 +11,8 @@ import showModal from "discourse/lib/show-modal";
 import { cookAsync } from "discourse/lib/text";
 import { markdownNameFromFileName } from "discourse/lib/uploads";
 import { base64ToBuffer } from "discourse/plugins/discourse-encrypt/lib/base64";
+import lightbox from "discourse/lib/lightbox";
+
 import {
   ENCRYPT_DISABLED,
   getDebouncedUserIdentities,
@@ -226,6 +228,18 @@ function postProcessPost(siteSettings, topicId, $post) {
     );
   }
 
+  $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>'
+      );
+    });
+  lightbox($post[0], siteSettings);
+
   try {
     const { linkSeenHashtags, fetchUnseenHashtags } = require.call(
       null,

GitHub sha: 63bc1481

This commit appears in #17 which was merged by lis2.