{{ 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 800) (and (isset .Params "width") (gt $image.Width (.Get "width"))) -}} {{ $.Scratch.Set "imgwidth" "800" }} {{ if and (isset .Params "width") (lt (.Get "width") 800) -}} {{ $.Scratch.Set "imgwidth" (trim (.Get "width") "px") }} {{- end }} {{ $resized := $image.Resize (printf "%sx Lanczos" ($.Scratch.Get "imgwidth")) }} {{ . }} {{ else }} {{ . }} {{- end }}