aboutsummaryrefslogtreecommitdiff
path: root/templates/shortcodes/imgswap.html
diff options
context:
space:
mode:
Diffstat (limited to 'templates/shortcodes/imgswap.html')
-rw-r--r--templates/shortcodes/imgswap.html17
1 files changed, 9 insertions, 8 deletions
diff --git a/templates/shortcodes/imgswap.html b/templates/shortcodes/imgswap.html
index efcf6e7..80a3b74 100644
--- a/templates/shortcodes/imgswap.html
+++ b/templates/shortcodes/imgswap.html
@@ -2,15 +2,16 @@
{%- set img = main_src | split(pat="/") | last %}
{%- set dirtest = main_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 main_src is starting_with("./") and reldir %} {# Relative Path #}
{%- set path = main_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 %}
@@ -31,9 +32,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 %}
@@ -55,9 +56,9 @@
{%- 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 %}
@@ -78,9 +79,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 %}