aboutsummaryrefslogtreecommitdiff
path: root/templates
diff options
context:
space:
mode:
authorJieiku2023-08-20 22:37:18 -0700
committerJieiku2023-08-20 22:37:18 -0700
commit61f2e1c3ac343163a5361686ad529c7039387310 (patch)
tree4be20065b86c9378cae2fe3f6de7079c3e3b2d3d /templates
parent4a9479325f07b1f73673cf95c1891229de9450dc (diff)
downloadabridge-61f2e1c3ac343163a5361686ad529c7039387310.tar.gz
abridge-61f2e1c3ac343163a5361686ad529c7039387310.tar.bz2
abridge-61f2e1c3ac343163a5361686ad529c7039387310.zip
fix image shortcodes for multilingual, and other optimizations
Diffstat (limited to 'templates')
-rw-r--r--templates/macros/macros.html3
-rw-r--r--templates/shortcodes/img.html17
-rw-r--r--templates/shortcodes/imgswap.html34
3 files changed, 42 insertions, 12 deletions
diff --git a/templates/macros/macros.html b/templates/macros/macros.html
index f994bdb..fb18345 100644
--- a/templates/macros/macros.html
+++ b/templates/macros/macros.html
@@ -148,9 +148,6 @@
{%- macro footer(page, config) %}
- {%- if page.reading_time and page.reading_time > 2 %}
- <p><b><a href="#">Back to top</a></b></p>
- {%- endif %}
{#- prev/next content page nextprev title pagination #}
{%- if not config.extra.hide_page_nextprev_titles | default(value=false) %}
{%- if page.lower or page.higher %}
diff --git a/templates/shortcodes/img.html b/templates/shortcodes/img.html
index a5a0541..d599ba0 100644
--- a/templates/shortcodes/img.html
+++ b/templates/shortcodes/img.html
@@ -6,7 +6,12 @@
{%- 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 %}
- {%- set meta = get_image_metadata(path=page.path ~ path ~ img) %}
+ {%- if lang != config.default_language %}
+ {%- set metapath = page.path ~ path ~ img | replace(from=page.path | truncate(length=4, end=""), to="/") %}
+ {%- else %}
+ {%- set metapath = page.path ~ path ~ img %}
+ {%- endif %}
+ {%- set meta = get_image_metadata(path=metapath) %}
{%- set w = meta.width %}
{%- set h = meta.height %}
{%- endif %}
@@ -15,7 +20,8 @@
{%- 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 metapath = rootpath ~ "/" ~ img %}
+ {%- set meta = get_image_metadata(path=metapath) %}
{%- set w = meta.width %}
{%- set h = meta.height %}
{%- endif %}
@@ -23,7 +29,12 @@
{%- else %} {# Same Directory Path #}
{%- set path = page.path %}
{%- if not w or not h %}
- {%- set meta = get_image_metadata(path=page.path ~ img) %}
+ {%- if lang != config.default_language %}
+ {%- set metapath = page.path ~ img | replace(from=page.path | truncate(length=4, end=""), to="/") %}
+ {%- else %}
+ {%- set metapath = page.path ~ img %}
+ {%- endif %}
+ {%- set meta = get_image_metadata(path=metapath) %}
{%- set w = meta.width %}
{%- set h = meta.height %}
{%- endif %}
diff --git a/templates/shortcodes/imgswap.html b/templates/shortcodes/imgswap.html
index e92d1bc..607febb 100644
--- a/templates/shortcodes/imgswap.html
+++ b/templates/shortcodes/imgswap.html
@@ -7,7 +7,12 @@
{%- 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 %}
- {%- set meta = get_image_metadata(path=page.path ~ path ~ img) %}
+ {%- if lang != config.default_language %}
+ {%- set metapath = page.path ~ path ~ img | replace(from=page.path | truncate(length=4, end=""), to="/") %}
+ {%- else %}
+ {%- set metapath = page.path ~ path ~ img %}
+ {%- endif %}
+ {%- set meta = get_image_metadata(path=metapath) %}
{%- set w = meta.width %}
{%- set h = meta.height %}
{%- endif %}
@@ -16,7 +21,8 @@
{%- set rootpath = main_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 metapath = rootpath ~ "/" ~ img %}
+ {%- set meta = get_image_metadata(path=metapath) %}
{%- set w = meta.width %}
{%- set h = meta.height %}
{%- endif %}
@@ -24,7 +30,12 @@
{%- else %} {# Same Directory Path #}
{%- set path = page.path %}
{%- if not w or not h %}
- {%- set meta = get_image_metadata(path=page.path ~ img) %}
+ {%- if lang != config.default_language %}
+ {%- set metapath = page.path ~ img | replace(from=page.path | truncate(length=4, end=""), to="/") %}
+ {%- else %}
+ {%- set metapath = page.path ~ img %}
+ {%- endif %}
+ {%- set meta = get_image_metadata(path=metapath) %}
{%- set w = meta.width %}
{%- set h = meta.height %}
{%- endif %}
@@ -43,7 +54,12 @@
{%- set path = swap_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 %}
- {%- set meta = get_image_metadata(path=page.path ~ path ~ img) %}
+ {%- if lang != config.default_language %}
+ {%- set metapath = page.path ~ path ~ img | replace(from=page.path | truncate(length=4, end=""), to="/") %}
+ {%- else %}
+ {%- set metapath = page.path ~ path ~ img %}
+ {%- endif %}
+ {%- set meta = get_image_metadata(path=metapath) %}
{%- set w = meta.width %}
{%- set h = meta.height %}
{%- endif %}
@@ -52,7 +68,8 @@
{%- set rootpath = swap_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 metapath = rootpath ~ "/" ~ img %}
+ {%- set meta = get_image_metadata(path=metapath) %}
{%- set w = meta.width %}
{%- set h = meta.height %}
{%- endif %}
@@ -60,7 +77,12 @@
{%- else %} {# Same Directory Path #}
{%- set path = page.path %}
{%- if not w or not h %}
- {%- set meta = get_image_metadata(path=page.path ~ img) %}
+ {%- if lang != config.default_language %}
+ {%- set metapath = page.path ~ img | replace(from=page.path | truncate(length=4, end=""), to="/") %}
+ {%- else %}
+ {%- set metapath = page.path ~ img %}
+ {%- endif %}
+ {%- set meta = get_image_metadata(path=metapath) %}
{%- set w = meta.width %}
{%- set h = meta.height %}
{%- endif %}