{{/*Retrive Passed Shortcode Parameters*/}} {{ $src := .Get "src" }} {{ $alt := .Get "alt" }} {{/*Define sizes*/}} {{ $Small := 200 }} {{ $Medium := 600 }} {{ $Large := 1000 }} {{/*Define Image variables as global variables to make them easily accessible in this shortcode*/}} {{ $DarkImage := "" }} {{ $DarkSmallImage := "" }} {{ $DarkMediumImage := "" }} {{ $DarkLargeImage := "" }} {{ $LightImage := "" }} {{ $LightSmallImage := "" }} {{ $LightMediumImage := "" }} {{ $LightLargeImage := "" }} {{ $SingleImage := "" }} {{ $SingleSmallImage := "" }} {{ $SingleMediumImage := "" }} {{ $SingleLargeImage := "" }} {{/*Find images and update the previous Single,Dark,Light Images variables*/}} {{ with resources.GetMatch (print $src ".jpg") }} {{ $SingleImage = . }} {{ end }} {{ with resources.GetMatch (print $src "-Dark" ".jpg") }} {{ $DarkImage = . }} {{ end }} {{ with resources.GetMatch (print $src "-Light" ".jpg") }} {{ $LightImage = . }} {{ end }} {{ with resources.GetMatch (print $src ".png") }} {{ $SingleImage = . }} {{ end }} {{ with resources.GetMatch (print $src "-Dark" ".png") }} {{ $DarkImage = . }} {{ end }} {{ with resources.GetMatch (print $src "-Light" ".png") }} {{ $LightImage = . }} {{ end }} {{/*Applying Image Processing*/}} {{ with $SingleImage }} {{ with .Resize (printf "%dx%d webp q50" .Width .Height) }} {{ $SingleImage = . }} {{ end }} {{ end }} {{ with $DarkImage }} {{ with .Resize (printf "%dx%d webp q50" .Width .Height) }} {{ $DarkImage = . }} {{ end }} {{ end }} {{ with $LightImage }} {{ with .Resize (printf "%dx%d webp q50" .Width .Height) }} {{ $LightImage = . }} {{ end }} {{ end }} {{/*Make different sized versions to images if applicable*/}} {{ with $SingleImage }} {{ if gt (.Width) ($Small) }} {{ with .Resize (printf "%dx" $Small) }} {{ $SingleSmallImage = . }} {{ end }} {{ end }} {{ if gt (.Width) ($Medium) }} {{ with .Resize (printf "%dx" $Medium) }} {{ $SingleMediumImage = . }} {{ end }} {{ end }} {{ if gt (.Width) ($Large) }} {{ with .Resize (printf "%dx" $Large) }} {{ $SingleLargeImage = . }} {{ end }} {{ end }} {{ end }} {{ with $DarkImage }} {{ if gt (.Width) ($Small) }} {{ with .Resize (printf "%dx" $Small) }} {{ $DarkSmallImage = . }} {{ end }} {{ end }} {{ if gt (.Width) ($Medium) }} {{ with .Resize (printf "%dx" $Medium) }} {{ $DarkMediumImage = . }} {{ end }} {{ end }} {{ if gt (.Width) ($Large) }} {{ with .Resize (printf "%dx" $Large) }} {{ $DarkLargeImage = . }} {{ end }} {{ end }} {{ end }} {{ with $LightImage }} {{ if gt (.Width) ($Small) }} {{ with .Resize (printf "%dx" $Small) }} {{ $LightSmallImage = . }} {{ end }} {{ end }} {{ if gt (.Width) ($Medium) }} {{ with .Resize (printf "%dx" $Medium) }} {{ $LightMediumImage = . }} {{ end }} {{ end }} {{ if gt (.Width) ($Large) }} {{ with .Resize (printf "%dx" $Large) }} {{ $LightLargeImage = . }} {{ end }} {{ end }} {{ end }} {{ if $SingleImage }} {{ with $SingleSmallImage }}{{ end }} {{ with $SingleMediumImage }}{{ end }} {{ with $SingleLargeImage }}{{ end }} {{ with $SingleImage }}{{ end }} {{ else }} {{ with $DarkSmallImage }}{{ end }} {{ with $DarkMediumImage }}{{ end }} {{ with $DarkLargeImage }}{{ end }} {{ with $DarkImage }}{{ end }} {{ with $LightSmallImage }}{{ end }} {{ with $LightMediumImage }}{{ end }} {{ with $LightLargeImage }}{{ end }} {{ with $LightImage }}{{ end }} {{ with $LightImage }} {{ else with $DarkImage }}{{ end }} {{ end }}