{{/* code from https://www.brycewray.com/posts/2023/05/better-code-image-processing-hugo-render-hook-edition/ */}} {{- $alt := .Text -}} {{- $caption := .Title -}} {{- $respSizes := slice "320" "640" "960" "1280" "1600" "1920" -}} {{- $hint := "photo" -}} {{- $filter := "box" -}} {{- $dest := ( .Destination | safeURL ) -}} {{- $dest = path.Join (path.Dir $dest) (path.Base $dest) -}}
{{- if and (.Page.Resources.Get $dest) (ne (.Page.Resources.Get $dest).MediaType.SubType "svg") -}} {{- $src := .Page.Resources.Get $dest -}} {{- $dataSzes := "(min-width: 1024px) 100vw, 50vw" -}} {{- $actualImg := $src.Resize (print "640x jpg " $filter) -}} {{ $alt }} {{- with $caption -}}

{{ $caption | $.Page.RenderString }}

{{- end }} {{- else -}}
{{ .Text }} {{- with $caption -}}
{{ $caption | $.Page.RenderString }}
{{- end }}
{{- end -}}