From b2efb92a53654685e4faca6aaab65f08dcfc62f3 Mon Sep 17 00:00:00 2001
From: Jonas Leder <jonas@jonasled.de>
Date: Sun, 1 May 2022 12:58:57 +0200
Subject: [PATCH] open preview when clicking on image

---
 js/customElements/image.js | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/js/customElements/image.js b/js/customElements/image.js
index f8e2440..e2bdb80 100644
--- a/js/customElements/image.js
+++ b/js/customElements/image.js
@@ -1,3 +1,5 @@
+import * as basicLightbox from 'basiclightbox'
+
 class CustomImage extends HTMLElement {
     async connectedCallback(){
         const originalURL = new URL(this.getAttribute("src"), document.baseURI).href;
@@ -28,6 +30,16 @@ class CustomImage extends HTMLElement {
         image.setAttribute("loading", "lazy");
         image.setAttribute("original-src", originalURL);
         this.appendChild(image);
+
+
+        if(!(this.getAttribute("data-noPreview") === "true")) {
+            image.onclick = () => {
+                const instance = basicLightbox.create(`
+                <img src="${originalURL}">
+                `);
+                instance.show();
+            }
+        }
     }
 }
 
-- 
GitLab