{{ $original := .Page.Resources.GetMatch (printf "*%s*" (.Get 0)) }} {{ $imgdata := imageConfig (printf "/content/%s" $original.RelPermalink) }} {{ if (gt $imgdata.Width 1500) }} {{ .Scratch.Set "image" ($original.Resize "1500x") }} {{ else if (gt $imgdata.Height 1500) }} {{ .Scratch.Set "image" ($original.Resize "x1500") }} {{ else }} {{ .Scratch.Set "image" $original }} {{ end }} {{ $image := .Scratch.Get "image" }} <figure style="padding: 0.25rem; margin: 2rem 0;"> <a href="{{ $original.RelPermalink }}"> <img style="max-width: 100%; width: auto; height: auto;" src="{{ $image.RelPermalink }}" width="{{ $image.Width }}" height="{{ $image.Height }}"> </a> <figcaption> {{ .Inner | markdownify }} </figcaption> </figure>