From 7492f62461a79e9d45df5086de0f306f8e340adc Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Thu, 2 Mar 2023 00:50:12 -0400 Subject: img file size cleanup was attempting to fix a bug with processing image file sizes and the issue turned out to be being on the wrong media branch THANKS --- src/misc-templates.js | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'src/misc-templates.js') diff --git a/src/misc-templates.js b/src/misc-templates.js index e8c7496..aa21a39 100644 --- a/src/misc-templates.js +++ b/src/misc-templates.js @@ -654,18 +654,27 @@ 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; const originalSrc = src; const thumbSrc = src && (thumbKey ? thumb[thumbKey](src) : src); + const href = + (willLink + ? (typeof link === 'string' + ? link + : originalSrc) + : null); + + let fileSize = null; + const mediaRoot = to('media.root'); + if (href?.startsWith(mediaRoot)) { + console.log(href.slice(mediaRoot.length).replace(/^\//, '')); + console.log(getSizeOfImageFile(href.slice(mediaRoot.length).replace(/^\//, ''))); + fileSize = getSizeOfImageFile(href.slice(mediaRoot.length).replace(/^\//, '')); + } + const imgAttributes = { id: link ? '' : id, class: className, @@ -734,7 +743,7 @@ function unbound_img({ { id, class: ['box', hide && 'js-hide', 'image-link'], - href: typeof link === 'string' ? link : originalSrc, + href, }, wrapped); } -- cgit 1.3.0-6-gf8a5