{{- $imgPath := .Destination -}} {{- $imgName := path.Base $imgPath | replaceRE "\\.[^.]+$" "" -}} {{- $dataPath := printf "data/images/%s.yaml" $imgName -}} {{- $dataFile := .Page.Resources.Get $dataPath -}} {{- $data := dict -}} {{- if $dataFile -}} {{- $data = $dataFile.Content | transform.Unmarshal -}} {{- end -}} {{- $alt := .PlainText | default $data.title | default "" -}} {{- $title := .Title | default $data.title | default .Page.Title -}} {{- $description := $data.description | default "" -}} {{- $image := .Page.Resources.GetMatch $imgPath -}} {{- if not $image -}} {{- return -}} {{- end -}} {{- $display := $image -}} {{- if and (ne $display.MediaType.SubType "svg") (gt $display.Height 810) -}} {{- $display = $image.Resize "x810" -}} {{- end -}} {{- $metaTitle := index $data "title" -}} {{- $hasMeta := or $metaTitle (or $description (or $data.attribution $data.prompt)) -}} {{- $attributes := .Attributes | default dict -}} {{- $imageClasses := "" -}} {{- with index $attributes "class" -}} {{- $imageClasses = lower (trim . " ") -}} {{- end -}} {{- $layout := "" -}} {{- with index $attributes "layout" -}} {{- $layout = lower (trim . " ") -}} {{- end -}} {{- $hasCenterClass := gt (len (findRE `(^|\\s)(center|centered)(\\s|$)` $imageClasses)) 0 -}} {{- $hasFullClass := gt (len (findRE `(^|\\s)(full|full-width|wide)(\\s|$)` $imageClasses)) 0 -}} {{- $forceCentered := false -}} {{- if or (in (slice "center" "centered") $layout) $hasCenterClass -}} {{- $forceCentered = true -}} {{- end -}} {{- if or (in (slice "full" "full-width" "wide") $layout) $hasFullClass -}} {{- $forceCentered = true -}} {{- end -}} {{- $forceWithoutMeta := false -}} {{- if or (in (slice "full" "full-width" "wide") $layout) $hasFullClass -}} {{- $forceWithoutMeta = true -}} {{- end -}} {{- $showMeta := and $hasMeta (not $forceWithoutMeta) -}} {{- $figureClasses := slice "figure-media" -}} {{- if $showMeta -}} {{- $figureClasses = $figureClasses | append "figure-media-with-meta" -}} {{- else -}} {{- $figureClasses = $figureClasses | append "figure-media-without-meta" -}} {{- end -}} {{- if $forceCentered -}} {{- $figureClasses = $figureClasses | append "figure-media-centered" -}} {{- end -}} {{- with $imageClasses -}} {{- $figureClasses = $figureClasses | append . -}} {{- end -}}
{{ $alt }} {{- if $showMeta -}}
{{- with $metaTitle -}}

{{ . | markdownify }}

{{- end -}} {{- with $description -}}

{{ . | markdownify }}

{{- end -}}
{{- if or $data.attribution $data.prompt -}}
{{- with $data.attribution -}}

Attribution : {{ . | markdownify }}

{{- end -}} {{- with $data.prompt -}}
Prompt

{{ . | markdownify }}

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