image: get resource images if link is prefixed with ./ #747

This commit is contained in:
Sören Weber 2023-12-05 14:45:35 +01:00
parent e95386a556
commit 8b9631705d
No known key found for this signature in database
GPG key ID: BEC6D55545451B6D

View file

@ -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") ",") }}