aboutsummaryrefslogtreecommitdiff
path: root/templates/shortcodes/img.html
diff options
context:
space:
mode:
authorJieiku2023-08-20 05:09:30 -0700
committerJieiku2023-08-20 05:09:30 -0700
commit4a9479325f07b1f73673cf95c1891229de9450dc (patch)
tree7b49e0ff046979b9ce75ff006a232adf10e3d806 /templates/shortcodes/img.html
parent211d08f9804c70943d7395175f25096483f006d0 (diff)
downloadabridge-4a9479325f07b1f73673cf95c1891229de9450dc.tar.gz
abridge-4a9479325f07b1f73673cf95c1891229de9450dc.tar.bz2
abridge-4a9479325f07b1f73673cf95c1891229de9450dc.zip
Fix image shortcodes, get_image_metadata()
Diffstat (limited to 'templates/shortcodes/img.html')
-rw-r--r--templates/shortcodes/img.html34
1 files changed, 19 insertions, 15 deletions
diff --git a/templates/shortcodes/img.html b/templates/shortcodes/img.html
index f23f783..a5a0541 100644
--- a/templates/shortcodes/img.html
+++ b/templates/shortcodes/img.html
@@ -1,30 +1,34 @@
+{%- set img = src | split(pat="/") | last %}
{%- set dirtest = src | trim_start_matches(pat="./") %}
-{%- if dirtest is containing("/") %}
- {%- set reldir = true %}
-{%- endif %}
+{%- if dirtest is containing("/") %} {%- set reldir = true %} {%- endif %}
{%- if src is starting_with("./") and reldir %} {# Relative Path #}
{%- set path = src | trim_start_matches(pat="./") | split(pat="/") | slice(end=-1) | join(sep="/") | trim_start_matches(pat="/") %}
- {%- set path = path ~ "/" %}
+ {%- set path = path ~ "/" %}
+ {%- if not w or not h %}
+ {%- set meta = get_image_metadata(path=page.path ~ path ~ img) %}
+ {%- set w = meta.width %}
+ {%- set h = meta.height %}
+ {%- endif %}
{%- elif src is starting_with("/") %} {# Root Path #}
{%- set rootpath = src | split(pat="/") | slice(end=-1) | join(sep="/") %}
{%- set path = config.base_url ~ rootpath ~ "/" %}
+ {%- if not w or not h %}
+ {%- set meta = get_image_metadata(path=rootpath ~ "/" ~ img) %}
+ {%- set w = meta.width %}
+ {%- set h = meta.height %}
+ {%- endif %}
{%- else %} {# Same Directory Path #}
- {%- set path = "" %}
-
+ {%- set path = page.path %}
+ {%- if not w or not h %}
+ {%- set meta = get_image_metadata(path=page.path ~ img) %}
+ {%- set w = meta.width %}
+ {%- set h = meta.height %}
+ {%- endif %}
{%- 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 %}
-
{%- if not alt %}
{%- set alt = img | split(pat=".") | first %}
{%- endif %}