From 4b447ad8d9110a949b69d8aa683d3d95193ca2f6 Mon Sep 17 00:00:00 2001
From: Brooke <12855764+goingforbrooke@users.noreply.github.com>
Date: Wed, 10 May 2023 21:38:33 -0700
Subject: [PATCH] Fix: properly link external images
This works by prepending the site's `base_url` to internal
image paths. Image URLs are deemed to be external if they
begin with `http`.
This fix was added to a PR for the Terminimal theme.
PR: https://github.com/pawroman/zola-theme-terminimal/pull/37
---
templates/shortcodes/image.html | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/templates/shortcodes/image.html b/templates/shortcodes/image.html
index 4450756..091eeb8 100644
--- a/templates/shortcodes/image.html
+++ b/templates/shortcodes/image.html
@@ -1,3 +1,8 @@
{% if src %}
-
+ {# If the image's URL is internal to the site... #}
+ {% if src is not starting_with("http") %}
+ {# ... then prepend the site's base URL to the image's URL. #}
+ {% set src = config.base_url ~ src %}
+ {% endif %}
+
{% endif %}