{{ if (fileExists (printf "%s/%s" "content" (replace (.Get "src") (path.Ext (.Get "src")) ".webp"))) -}} {{- end }} {{ $image := $.Page.Resources.GetMatch (.Get "src") }} {{ if or (gt $image.Width 1600) (and (isset .Params "width") (gt $image.Width (.Get "width"))) -}} {{ $.Scratch.Set "imgwidth" "1600" }} {{ if and (isset .Params "width") (lt (.Get "width") 1600) -}} {{ $.Scratch.Set "imgwidth" (mul (int (trim (.Get "width") "px")) 2) }} {{- end }} {{ $resized := $image.Resize (printf "%dx Lanczos" ($.Scratch.Get "imgwidth")) }} {{ . }} {{ else }} {{ . }} {{- end }}