{{/* Automatic resizing for HiDPI/retina images */}} {{ $original := .Page.Resources.GetMatch (.Get "src") }} {{ .Scratch.Set "image" $original }} {{ $setWidth := .Site.Params.maxWidth }} {{ if .Get "width" }} {{ $setWidth = (int (.Get "width")) }} {{ end }} {{ $retinaWidth := (mul $setWidth 2) }} {{ if gt $original.Width $retinaWidth -}} {{ $finalWidth := (printf "%dx" $retinaWidth) }} {{ .Scratch.Set "image" ($original.Resize $finalWidth) }} {{ end }} {{ $image := .Scratch.Get "image" }} {{ $origRatio := (div (float $image.Height) $image.Width) }} {{ $displayWidth := $setWidth }} {{ $displayHeight := (math.Ceil (mul $origRatio $setWidth)) }} {{ return (dict "Permalink" $image.Permalink "Width" $displayWidth "Height" $displayHeight "MediaType" $image.MediaType) }}