{{/* Avoid using this on images less than 4x*35em*16px = 2240 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 -}} {{ $bodyWidth := site.Params.bodyWidthEM | default 45 -}} {{ $wide := mul $bodyWidth 1.5 | default 67.5 -}} {{ $phoneWidth := mul $bodyWidth 0.7777777777777778 | default 35 -}} {{ $widths := site.Params.screenWidths -}} {{ $divideBy := site.Params.divideViewportBy | default 4 -}} {{ $percent := div 100 $divideBy | default 25 -}} {{ $fallback := site.Params.fallbackSize | default 1440 -}} {{ range $widths -}} {{ if and (ge $src.Width (div . $divideBy)) (ge . (mul $wide 16)) -}} {{ $srcUrl := (printf "%dx" (div . $divideBy) | $src.Resize).RelPermalink -}} {{ if and (eq $imgSrc "") (ge . $fallback) }}{{ $imgSrc = $srcUrl }}{{ end -}} {{ $imgSrcSet = $imgSrcSet | append (printf "%s %dw" $srcUrl (div . $divideBy)) -}} {{ end -}} {{ end -}} {{ if eq $imgSrc "" }}{{ $imgSrc = $src.RelPermalink }}{{ end -}} {{ $imgSrcSet = (delimit $imgSrcSet ",\n\t") -}}