« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/misc-templates.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/misc-templates.js')
-rw-r--r--src/misc-templates.js9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/misc-templates.js b/src/misc-templates.js
index 171b4825..e8c7496c 100644
--- a/src/misc-templates.js
+++ b/src/misc-templates.js
@@ -637,7 +637,9 @@ function unbound_getFlashGridHTML({
 // Images
 
 function unbound_img({
+  getSizeOfImageFile,
   html,
+  to,
 
   src,
   alt,
@@ -652,6 +654,12 @@ function unbound_img({
   lazy = false,
   square = false,
 }) {
+  let fileSize = null;
+  const mediaRoot = to('media.root');
+  if (src.startsWith(mediaRoot)) {
+    fileSize = getSizeOfImageFile(src.slice(mediaRoot.length).replace(/^\//, ''));
+  }
+
   const willSquare = square;
   const willLink = typeof link === 'string' || link;
 
@@ -664,6 +672,7 @@ function unbound_img({
     alt,
     width,
     height,
+    'data-original-size': fileSize,
   };
 
   const noSrcHTML =