{{- $src := (.Destination | safeURL) -}} {{- $fragments := (split $src "#") -}} {{- $src = index ($fragments) 0 -}} {{- $imgwidth := .Page.Scratch.Get "imgwidth" | default 800 -}} {{- $src = path.Base $src -}} {{- with (.Page.Resources.ByType "image").GetMatch (printf "**/%s" $src) -}} {{ $resized := . }} {{ if (gt .Width $imgwidth) }} {{ if hugo.IsExtended }} {{- $resized = .Resize (print $imgwidth "x webp") -}} {{ else }} {{- $resized = .Resize (print $imgwidth "x") -}} {{ end }} {{ end }} {{ $placeholder := "" }} {{- if or (eq .MediaType.SubType "jpg") (eq .MediaType.SubType "jpeg") }} {{ $placeholder = .Resize "48x q20 jpg Gaussian" }} {{ end -}} {{- if (eq .MediaType.SubType "gif") }} {{ $resized = . }} {{ end -}} {{ $.Text }} {{- else -}} {{ .Text }} {{- end -}}