« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/static
diff options
context:
space:
mode:
Diffstat (limited to 'src/static')
-rw-r--r--src/static/client2.js16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/static/client2.js b/src/static/client2.js
index 758d91a6..523b48d8 100644
--- a/src/static/client2.js
+++ b/src/static/client2.js
@@ -954,10 +954,14 @@ function handleImageLinkClicked(evt) {
   const thumbImage = document.getElementById('image-overlay-image-thumb');
 
   const {href: originalSrc} = evt.target.closest('a');
-  const {dataset: {
-    originalSize: originalFileSize,
-    thumbs: availableThumbList,
-  }} = evt.target.closest('a').querySelector('img');
+
+  const {
+    src: embeddedSrc,
+    dataset: {
+      originalSize: originalFileSize,
+      thumbs: availableThumbList,
+    },
+  } = evt.target.closest('a').querySelector('img');
 
   updateFileSizeInformation(originalFileSize);
 
@@ -967,8 +971,8 @@ function handleImageLinkClicked(evt) {
   if (availableThumbList) {
     const {thumb: mainThumb, length: mainLength} = getPreferredThumbSize(availableThumbList);
     const {thumb: smallThumb, length: smallLength} = getSmallestThumbSize(availableThumbList);
-    mainSrc = originalSrc.replace(/\.(jpg|png)$/, `.${mainThumb}.jpg`);
-    thumbSrc = originalSrc.replace(/\.(jpg|png)$/, `.${smallThumb}.jpg`);
+    mainSrc = embeddedSrc.replace(/\.[a-z]+\.(jpg|png)$/, `.${mainThumb}.jpg`);
+    thumbSrc = embeddedSrc.replace(/\.[a-z]+\.(jpg|png)$/, `.${smallThumb}.jpg`);
     // Show the thumbnail size on each <img> element's data attributes.
     // Y'know, just for debugging convenience.
     mainImage.dataset.displayingThumb = `${mainThumb}:${mainLength}`;