{{/* Avoid using this shortcode on images less than 3840 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.screenWidths -}} {{ $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") -}}