theme: fix image urls if uglyURLs=true #370

This commit is contained in:
Sören Weber 2022-11-05 23:58:24 +01:00
parent b9e97bcc0b
commit f2523234bd
No known key found for this signature in database
GPG key ID: BEC6D55545451B6D

View file

@ -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 }}
<img src="{{ $url }}" alt="{{ .Text }}"{{ with .Title}} title="{{ . }}"{{ end }}>