From f2523234bd2cbffe9cd7badb96fdf2907f5719f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Weber?= Date: Sat, 5 Nov 2022 23:58:24 +0100 Subject: [PATCH] theme: fix image urls if uglyURLs=true #370 --- layouts/_default/_markup/render-image.html | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 layouts/_default/_markup/render-image.html diff --git a/layouts/_default/_markup/render-image.html b/layouts/_default/_markup/render-image.html new file mode 100644 index 0000000000..44d9597a96 --- /dev/null +++ b/layouts/_default/_markup/render-image.html @@ -0,0 +1,11 @@ +{{- $dest_url := urls.Parse .Destination }} +{{- $dest_path := $dest_url.Path }} +{{- $image := .Page.Resources.GetMatch $dest_path }} +{{- $url := .Destination | relURL }} +{{- if $image }} + {{- $url = $image.RelPermalink }} + {{- if $dest_url.RawQuery }} + {{- $url = printf "%s?%s" $url $dest_url.RawQuery }} + {{- end }} +{{- end }} +{{ .Text }}