{{/* see https://dev.to/stereobooster/responsive-images-for-hugo-dn9 for more information */}} {{/* 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 */}} {{ $lqipw := default "20x" }} {{ $tinyw := default "500x" }} {{ $smallw := default "800x" }} {{ $mediumw := default "1200x" }} {{ $largew := default "1500x" }} {{/* resize the src image to the given sizes */}} {{ $lqip := $src.Resize $lqipw }} {{ $tiny := $src.Resize $tinyw }} {{ $small := $src.Resize $smallw }} {{ $medium := $src.Resize $mediumw }} {{ $large := $src.Resize $largew }} {{/* 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 */}} {{ $img := imageConfig ($src.RelPermalink | printf "content/%s" ) }}