« get me outta code hell

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:
Diffstat (limited to 'src/content/dependencies/image.js')
-rw-r--r--src/content/dependencies/image.js17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/content/dependencies/image.js b/src/content/dependencies/image.js
index 134f99c..93e7658 100644
--- a/src/content/dependencies/image.js
+++ b/src/content/dependencies/image.js
@@ -69,8 +69,6 @@ export default {
     },
 
     alt: {type: 'string'},
-    width: {type: 'number'},
-    height: {type: 'number'},
 
     attributes: {
       type: 'attributes',
@@ -139,8 +137,13 @@ export default {
       !isMissingImageFile &&
       !empty(contentWarnings);
 
+    const hasBothDimensions =
+      !!(slots.dimensions &&
+         slots.dimensions[0] !== null &&
+         slots.dimensions[1] !== null);
+
     const willSquare =
-      (slots.dimensions
+      (hasBothDimensions
         ? slots.dimensions[0] === slots.dimensions[1]
         : slots.square);
 
@@ -148,8 +151,12 @@ export default {
       {class: 'image'},
 
       slots.alt && {alt: slots.alt},
-      slots.width && {width: slots.width},
-      slots.height && {height: slots.height},
+
+      slots.dimensions?.[0] &&
+        {width: slots.dimensions[0]},
+
+      slots.dimensions?.[1] &&
+        {width: slots.dimensions[1]},
     ]);
 
     const isPlaceholder =