« get me outta code hell

content: image: take dimensions slot, more powerful than square - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2024-04-13 15:27:21 -0300
committer(quasar) nebula <qznebula@protonmail.com>2024-04-13 15:47:35 -0300
commitd23bf7443177a85f4c8bf9521dc63da7ccfdd799 (patch)
tree9c60b67c840a90336a09256098eaf1469249e60d /src
parent2143d55665f1899375b99c208745cf8c62c782e0 (diff)
content: image: take dimensions slot, more powerful than square
Diffstat (limited to 'src')
-rw-r--r--src/content/dependencies/image.js10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/content/dependencies/image.js b/src/content/dependencies/image.js
index db307a6b..134f99c9 100644
--- a/src/content/dependencies/image.js
+++ b/src/content/dependencies/image.js
@@ -61,8 +61,13 @@ export default {
 
     reveal: {type: 'boolean', default: true},
     lazy: {type: 'boolean', default: false},
+
     square: {type: 'boolean', default: false},
 
+    dimensions: {
+      validate: v => v.isDimensions,
+    },
+
     alt: {type: 'string'},
     width: {type: 'number'},
     height: {type: 'number'},
@@ -134,7 +139,10 @@ export default {
       !isMissingImageFile &&
       !empty(contentWarnings);
 
-    const willSquare = slots.square;
+    const willSquare =
+      (slots.dimensions
+        ? slots.dimensions[0] === slots.dimensions[1]
+        : slots.square);
 
     const imgAttributes = html.attributes([
       {class: 'image'},