{{/* Figure Shortcode for Wowchemy. */}} {{/* Load image from page dir falling back to media library at `assets/images/` and then to remote URI. */}} {{ $destination := .Get "src" }} {{ $caption := .Get "title" | default (.Get "caption") | default "" }} {{ $id := .Get "id" | default $caption }} {{ $alt := .Get "alt" | default ($caption | plainify) }} {{- $img := (.Page.Resources.ByType "image").GetMatch $destination -}} {{- if and (not $img) .Page.File -}} {{ $path := $destination }} {{- $img = resources.Get (path.Join "images" $path) -}} {{- end -}}
{{- if $img -}} {{ $isSVG := eq $img.MediaType.SubType "svg" }} {{ if $isSVG }} {{ $img.Content | safeHTML }} {{ else }} {{- $img_lg := $img.Fit "1200x1200" -}} {{- $img_md := $img_lg.Fit "760x760" -}}{{/* Match `.docs-article-container` max-width */}} {{- $img_sm := $img_md.Fit "400x400" -}} {{ $alt }} {{ end }} {{- else -}} {{ $alt }} {{- end -}} {{ if $caption }} {{/* Localize the figure numbering (if enabled). */}} {{ $figure := split (i18n "figure" | default "Figure %d:") "%d" }} {{ $caption | markdownify | emojify }} {{ end }}