{{/* Avoid using this on images less than 4x*45em*16px = 2880 pixels wide */ -}} {{/* get file that matches the filename as specified as src="" in shortcode */}} {{ $src := .Page.Resources.GetMatch (printf "*%s*" (.Get "src")) -}} {{ $imgSrc := "" -}} {{ $imgSrcSet := slice -}} {{ $widths := site.Params.bodyPhotoWidths -}} {{ $body := site.Params.bodyWidthEM | default 45 -}} {{ $fallback := site.Params.fallbackSize | default 1440 -}} {{ range $widths -}} {{ if ge $src.Width . -}} {{ $srcUrl := (printf "%dx" . | $src.Resize).RelPermalink -}} {{ if and (eq $imgSrc "") (ge . $fallback) }}{{ $imgSrc = $srcUrl }}{{ end -}} {{ $imgSrcSet = $imgSrcSet | append (printf "%s %dw" $srcUrl .) -}} {{ end -}} {{ end -}} {{ if eq $imgSrc "" }}{{ $imgSrc = $src.RelPermalink }}{{ end -}} {{ $imgSrcSet = (delimit $imgSrcSet ",\n\t") -}}