« get me outta code hell

content, client: integrate separate media cache - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/content/dependencies/image.js
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2023-10-29 15:29:20 -0300
committer(quasar) nebula <qznebula@protonmail.com>2023-10-29 15:43:32 -0300
commit482edbc0ff58da60e51a5f41f8888873d8740a03 (patch)
tree327b8aa2e35bd514dcd1183c53907f1c8c651397 /src/content/dependencies/image.js
parent08da5be83b7fe7f67ce861fa311ce9b32bb22f55 (diff)
content, client: integrate separate media cache
Diffstat (limited to 'src/content/dependencies/image.js')
-rw-r--r--src/content/dependencies/image.js7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/content/dependencies/image.js b/src/content/dependencies/image.js
index 6c0aeec..8aa9753 100644
--- a/src/content/dependencies/image.js
+++ b/src/content/dependencies/image.js
@@ -77,6 +77,11 @@ export default {
       originalSrc = '';
     }
 
+    // TODO: This feels janky. It's necessary to deal with static content that
+    // includes strings like <img src="media/misc/foo.png">, but processing the
+    // src string directly when a parts-formed path *is* available seems wrong.
+    // It should be possible to do urls.from(slots.path[0]).to(...slots.path),
+    // for example, but will require reworking the control flow here a little.
     let mediaSrc = null;
     if (originalSrc.startsWith(to('media.root'))) {
       mediaSrc =
@@ -160,7 +165,7 @@ export default {
       // which is the HTML output-appropriate path including `../../` or
       // another alternate base path.
       const selectedSize = getThumbnailEqualOrSmaller(slots.thumb, mediaSrc);
-      thumbSrc = originalSrc.replace(/\.(jpg|png)$/, `.${selectedSize}.jpg`);
+      thumbSrc = to('thumb.path', mediaSrc.replace(/\.(png|jpg)$/, `.${selectedSize}.jpg`));
 
       const dimensions = getDimensionsOfImagePath(mediaSrc);
       availableThumbs = getThumbnailsAvailableForDimensions(dimensions);