{{- $path := (.Get "src") -}} {{- $original := .Page.Resources.GetMatch $path -}} {{- if not $original -}} {{- errorf "couldn't find resource for src: %s" $path -}} {{- else if and (ne "jpeg" $original.MediaType.SubType) (ne "png" $original.MediaType.SubType) -}} {{- errorf "src %s is a '%s', expected 'jpeg' or 'png'" $path $original.MediaType.SubType -}} {{- else -}} {{- /* Below is a copy paste of https://github.com/gohugoio/hugo/blob/master/tpl/tplimpl/embedded/templates/shortcodes/figure.html from Hugo commit aba2647c152ffff927f42523b77ee6651630cd67, with the img tag modified to use srcsets */ -}} {{- /* Note that it presently uses `markdownify` instead of $.Page.RenderString for consistency with Hugo's `figure` shortcode. */ -}} {{- if .Get "link" -}} {{- end }} {{ if (or (ge $original.Width 1304) (ge $original.Height 1304)) -}} {{/* Add the original to the droplist, so it will get removed later. */}} {{- if not (.Page.Scratch.Get "droplist") -}} {{- .Page.Scratch.Set "droplist" (slice) -}} {{- end -}} {{- .Page.Scratch.Add "droplist" $original.RelPermalink -}} {{/* Note: 652px is the max width of an img in article content. I measured this using dev tools; but it's dependent on the styles for the page. */}} {{- $resized_1x := $original.Fit "652x652 q95" -}} {{- $resized_2x := $original.Fit "1304x1304 q95" -}} {{ with .Get {{- if .Get "link" }}{{ end -}} {{- if or (or (.Get "title") (.Get "caption")) (.Get "attr") }}
{{ with (.Get "title") -}}

{{ . }}

{{- end -}} {{- if or (.Get "caption") (.Get "attr") -}}

{{- .Get "caption" | markdownify -}} {{- with .Get "attrlink" }} {{- end -}} {{- .Get "attr" | markdownify -}} {{- if .Get "attrlink" }}{{ end }}

{{- end }}
{{- end }} {{- end -}}