{{ $light_gif := resources.GetMatch (printf "/p/%s.gif" (.Get "name")) -}} {{ $light_svg := resources.GetMatch (printf "/p/%s.svg" (.Get "name")) -}} {{ $light_png := resources.GetMatch (printf "/p/%s.png" (.Get "name")) -}} {{ $light_jpg := resources.GetMatch (printf "/p/%s.jpg" (.Get "name")) -}} {{ $light_webp := resources.GetMatch (printf "/p/%s.webp" (.Get "name")) -}} {{ $light_avif := resources.GetMatch (printf "/p/%s.avif" (.Get "name")) -}} {{ $light_jxl := resources.GetMatch (printf "/p/%s.jxl" (.Get "name")) -}} {{ $dark_svg := resources.GetMatch (printf "/p/%s_dark.svg" (.Get "name")) -}} {{ $dark_gif := resources.GetMatch (printf "/p/%s_dark.gif" (.Get "name")) -}} {{ $dark_png := resources.GetMatch (printf "/p/%s_dark.png" (.Get "name")) -}} {{ $dark_jpg := resources.GetMatch (printf "/p/%s_dark.jpg" (.Get "name")) -}} {{ $dark_webp := resources.GetMatch (printf "/p/%s_dark.webp" (.Get "name")) -}} {{ $dark_avif := resources.GetMatch (printf "/p/%s_dark.avif" (.Get "name")) -}} {{ $dark_jxl := resources.GetMatch (printf "/p/%s_dark.jxl" (.Get "name")) -}} {{ $alt := .Get "alt" -}} {{- $orig_img := $light_png -}} {{- $orig_img_type := "image/png" -}} {{- $orig_img_dark := $dark_png -}} {{- $orig_img_dark_type := "image/png" -}} {{- with $light_jpg -}} {{- $orig_img_type = "image/jpeg" -}} {{- $orig_img = $light_jpg -}} {{- end -}} {{- with $light_gif -}} {{- $orig_img_type = "image/gif" -}} {{- $orig_img = $light_gif -}} {{- end -}} {{- with $dark_jpg -}} {{- $orig_img_dark_type = "image/jpeg" -}} {{- $orig_img_dark = $dark_jpg -}} {{- end -}} {{- with $dark_gif -}} {{- $orig_img_dark_type = "image/gif" -}} {{- $orig_img_dark = $dark_gif -}} {{- end -}} {{- $img_width := 0 -}} {{- with .Get "width" -}} {{- $img_width = . -}} {{- else -}} {{- $img_width = $orig_img.Width -}} {{- end -}} {{- $img_height := 0 -}} {{- with .Get "height" -}} {{- $img_height = . -}} {{- else -}} {{- $img_height = $orig_img.Height -}} {{- end -}} {{- with (.Get "sf") -}} {{- $img_width = (mul $img_width . | math.Round) -}} {{- $img_height = (mul $img_height . | math.Round ) -}} {{- end -}} {{- if not (in site.BaseURL ".onion") -}} {{ with $dark_svg -}} {{ $dark_svg_src := partial "cache-bust.html" . -}} {{ end -}} {{ end -}} {{ with $dark_jxl -}} {{ $dark_jxl_src := partial "cache-bust.html" . -}} {{ end -}} {{ with $dark_avif -}} {{ $dark_avif_src := partial "cache-bust.html" . -}} {{ end -}} {{ with $dark_webp -}} {{ $dark_webp_src := partial "cache-bust.html" . -}} {{ end -}} {{ with $orig_img_dark -}} {{ $orig_dark_src := partial "cache-bust.html" . -}} {{ end -}} {{- if not (in site.BaseURL ".onion") -}} {{ with $light_svg -}} {{ $light_svg_src := partial "cache-bust.html" . -}} {{ end -}} {{ end -}} {{ with $light_jxl -}} {{ $light_jxl_src := partial "cache-bust.html" . -}} {{ end -}} {{ with $light_avif -}} {{ $light_avif_src := partial "cache-bust.html" . -}} {{ end -}} {{ with $light_webp -}} {{ $light_webp_src := partial "cache-bust.html" . -}} {{ end -}} {{ $orig_src := partial "cache-bust.html" $orig_img -}} {{- /* Strip trailing newline: https://github.com/gohugoio/hugo/issues/1753 */ -}}