From 8b9631705dfab9bff498d57fe2381396c48ef2d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Weber?= Date: Tue, 5 Dec 2023 14:45:35 +0100 Subject: [PATCH] image: get resource images if link is prefixed with ./ #747 --- layouts/partials/shortcodes/image.html | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/layouts/partials/shortcodes/image.html b/layouts/partials/shortcodes/image.html index b812049f3b..372981892d 100644 --- a/layouts/partials/shortcodes/image.html +++ b/layouts/partials/shortcodes/image.html @@ -17,7 +17,7 @@ {{- $width := "auto" }} {{- $dest_url := urls.Parse $url }} {{- $dest_path := $dest_url.Path }} -{{- $image := $page.Resources.GetMatch $dest_path }} +{{- $image := $page.Resources.GetMatch (path.Clean $dest_url.Path) }} {{- if not $image }} {{- $image = .Resources.GetMatch $dest_path }} {{- end }} @@ -30,6 +30,11 @@ {{- $url = printf "%s?%s" $url $dest_url.RawQuery }} {{- end }} {{- end }} +{{- if not $image }} + {{- if and ($page.Site.Params.render_hooks.errorlevel "warning") (not (or (strings.HasPrefix .url "http://") (strings.HasPrefix .url "https://") )) }} + {{- warnf "%q: Image %s is not a resource but linked anyways." $page.File.Filename .url }} + {{- end }} +{{- end }} {{- if $dest_url.RawQuery }} {{- if $dest_url.Query.Has "classes" }} {{- $classes := slice | append (split ($dest_url.Query.Get "classes") ",") }}