hugo-theme-relearn/layouts/_default/_markup/render-image.html
2022-11-05 23:58:24 +01:00

11 lines
412 B
HTML

{{- $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 }}>