aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJieiku2022-07-27 22:46:21 -0700
committerJieiku2022-07-27 22:46:21 -0700
commit0e57376f244848c6513236424dffb63acd15271c (patch)
tree7815270c6072ff49104bb4ea142c663b4a39b724
parentfe718cfb3b63bce0dcc8766d32b1f86f8cc65ade (diff)
downloadabridge-0e57376f244848c6513236424dffb63acd15271c.tar.gz
abridge-0e57376f244848c6513236424dffb63acd15271c.tar.bz2
abridge-0e57376f244848c6513236424dffb63acd15271c.zip
img/imghover shortcodes optional width/height
-rw-r--r--templates/shortcodes/img.html7
-rw-r--r--templates/shortcodes/imghover.html5
-rw-r--r--theme.toml2
3 files changed, 11 insertions, 3 deletions
diff --git a/templates/shortcodes/img.html b/templates/shortcodes/img.html
index 4645569..cf2a562 100644
--- a/templates/shortcodes/img.html
+++ b/templates/shortcodes/img.html
@@ -16,6 +16,13 @@
{%- endif %}
+{%- if not w or not h %}
+ {%- set metafile = page.path ~ path ~ src %}
+ {%- set meta = get_image_metadata(path=metafile) %}
+ {%- set w = meta.width %}
+ {%- set h = meta.height %}
+{%- endif %}
+
{%- set img = src | split(pat="/") | last %}
{%- set name = img | split(pat=".") | first %}
<img src="{{ path | safe }}{{ img | safe }}"{% if class %} class="{{class}}"{% endif %}{% if alt %} alt="{{alt}}"{% endif %}{% if w %} width="{{w}}"{% endif %}{% if h %} height="{{h}}"{% endif %} />
diff --git a/templates/shortcodes/imghover.html b/templates/shortcodes/imghover.html
index b1af3f9..1ad733c 100644
--- a/templates/shortcodes/imghover.html
+++ b/templates/shortcodes/imghover.html
@@ -69,9 +69,10 @@
{%- set metafile = page.path ~ path ~ sourcepath %}
{%- set meta = get_image_metadata(path=metafile) %}
{%- set padding = meta.height / meta.width * p %}
- /* height={{meta.height}} width={{meta.width}} (THIS IS BACKWARDS!?) */
{%- else %}
- {%- set padding = 50 %}
+ {%- set metafile = page.path ~ path ~ sourcepath %}
+ {%- set meta = get_image_metadata(path=metafile) %}
+ {%- set padding = meta.height / meta.width * 50 %}
{%- endif %}
diff --git a/theme.toml b/theme.toml
index d3ab04f..23a557a 100644
--- a/theme.toml
+++ b/theme.toml
@@ -2,7 +2,7 @@ name = "abridge"
description = "A fast and lightweight Zola theme using semantic html, a class-light abridge.css, and No JS."
license = "MIT"
homepage = "https://github.com/jieiku/abridge/"
-min_version = "0.14.1"
+min_version = "0.16.0"
demo = "https://abridge.netlify.app/"
[extra]