From db205d3d20946f64de5f66635fcb3335feebbaaa Mon Sep 17 00:00:00 2001 From: eugenchio Date: Fri, 20 Dec 2024 12:10:13 +0200 Subject: [PATCH] Fix lightbox initialization. --- static/js/lightbox.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/static/js/lightbox.js b/static/js/lightbox.js index 8339a33..9b6b957 100644 --- a/static/js/lightbox.js +++ b/static/js/lightbox.js @@ -12,13 +12,12 @@ window.addEventListener("load", function () { if (img.parentNode.tagName === "A") { img.parentNode.setAttribute("data-pswp-width", img.naturalWidth); img.parentNode.setAttribute("data-pswp-height", img.naturalHeight); + + const lightbox = new PhotoSwipeLightbox({ + gallery: img.parentNode, + pswpModule: PhotoSwipe + }); + lightbox.init(); } }); - - const options = { - gallery: '.narrow-container a', - pswpModule: PhotoSwipe - }; - const lightbox = new PhotoSwipeLightbox(options); - lightbox.init(); });