{{/* get file that matches the filename as specified as src="" in shortcode */}} {{ $src := .Page.Resources.GetMatch (printf "*%s*" (.Get "src")) }} {{/* set image sizes, these are hardcoded for now, x dictates that images are resized to this width */}} {{ $tinyw := default "500x" }} {{ $smallw := default "800x" }} {{ $mediumw := default "1200x" }} {{ $largew := default "1500x" }} {{/* resize the src image to the given sizes */}} {{ .Scratch.Set "tiny" ($src.Resize $tinyw) }} {{ .Scratch.Set "small" ($src.Resize $smallw) }} {{ .Scratch.Set "medium" ($src.Resize $mediumw) }} {{ .Scratch.Set "large" ($src.Resize $largew) }} {{/* add the processed images to the scratch */}} {{ $tiny := .Scratch.Get "tiny" }} {{ $small := .Scratch.Get "small" }} {{ $medium := .Scratch.Get "medium" }} {{ $large := .Scratch.Get "large" }} {{/* only use images smaller than or equal to the src (original) image size, as Hugo will upscale small images */}} {{/* set the sizes attribute to (min-width: 35em) 1200px, 100vw unless overridden in shortcode */}}