aboutsummaryrefslogtreecommitdiff
path: root/templates/shortcodes/img.html
diff options
context:
space:
mode:
Diffstat (limited to 'templates/shortcodes/img.html')
-rw-r--r--templates/shortcodes/img.html9
1 files changed, 5 insertions, 4 deletions
diff --git a/templates/shortcodes/img.html b/templates/shortcodes/img.html
index f5754ce..ac3ba6b 100644
--- a/templates/shortcodes/img.html
+++ b/templates/shortcodes/img.html
@@ -1,15 +1,16 @@
{%- set img = src | split(pat="/") | last %}
{%- set dirtest = src | trim_start_matches(pat="./") %}
{%- if dirtest is containing("/") %} {%- set reldir = true %} {%- endif %}
+{%- if page.path %}{%- set pagepath = page.path %}{%- elif section.path %}{%- set pagepath = section.path %}{%- 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 ~ "/" %}
{%- if not w or not h %}
{%- if lang != config.default_language %}
- {%- set metapath = page.path ~ path ~ img | replace(from=page.path | truncate(length=4, end=""), to="/") %}
+ {%- set metapath = pagepath ~ path ~ img | replace(from=pagepath | truncate(length=4, end=""), to="/") %}
{%- else %}
- {%- set metapath = page.path ~ path ~ img %}
+ {%- set metapath = pagepath ~ path ~ img %}
{%- endif %}
{%- set meta = get_image_metadata(path=metapath) %}
{%- set w = meta.width %}
@@ -30,9 +31,9 @@
{%- set path = "" %}
{%- if not w or not h %}
{%- if lang != config.default_language %}
- {%- set metapath = page.path ~ img | replace(from=page.path | truncate(length=4, end=""), to="/") %}
+ {%- set metapath = pagepath ~ img | replace(from=pagepath | truncate(length=4, end=""), to="/") %}
{%- else %}
- {%- set metapath = page.path ~ img %}
+ {%- set metapath = pagepath ~ img %}
{%- endif %}
{%- set meta = get_image_metadata(path=metapath) %}
{%- set w = meta.width %}