{{/* Enable image to be loaded from local page dir or media library at `static/img/`. */}} {{ $asset := (.Page.Resources.ByType "image").GetMatch (.Get "src") }} {{ $image_src := (.Get "src") }} {{ if $asset }} {{ $asset2 := $asset.Fit "2000x2000" }} {{ $image_src = $asset2.RelPermalink }} {{ else if .Get "library" }} {{ $image_src = printf "img/%s" $image_src | relURL }} {{ end }} {{/* Disallow user from opening image in the lightbox? */}} {{ $lightbox := eq (.Get "lightbox" | default "true") "true" }} {{/* Get lightbox group for showing multiple images in a lightbox. */}} {{ $group := .Get "lightbox-group" | default "" }} {{/* Get caption. Support legacy `title` option. */}} {{ $caption := .Get "title" | default (.Get "caption") | default "" }} {{ if $lightbox }} {{ else if .Get "link"}} {{ end -}} {{/* Lazy load only when we know image dimensions in order to preserve anchor linking. */}} {{ if $asset }} {{ with .Get {{ else if and (.Get "width") (.Get "height") }} {{ with .Get {{ else }} {{ with .Get {{ end }} {{- if or $lightbox (.Get "link") }}{{ end }} {{ if $caption }} {{/* Localize the figure numbering (if enabled). */}} {{ $figure := split (i18n "figure" | default "Figure %d:") "%d" }} {{ $caption | markdownify | emojify }} {{ end }}