{{- /*
A Markdown image has three components: the image description, the image destination, and optionally the image title.

![white kitten](/images/kitten.jpg "A kitten!")
  ------------  ------------------  ---------
  description      destination        title
  ------------  ------------------  ---------
  .Text            .Destination       .Title
*/ -}}
{{- $optim := slice
  (dict "Process" "resize 800x webp" "descriptor" "800w")
  (dict "Process" "resize 1200x webp" "descriptor" "1200w")
  (dict "Process" "resize 1600x webp" "descriptor" "1600w")
-}}
{{- $lightgallery := .Page.Param "lightgallery" -}}
{{- if .Title -}}
  {{- $linked := ne $lightgallery false -}}
  <figure>
    {{- dict "Page" .Page "Src" .Destination "Alt" .PlainText "Title" .Title "Caption" .Text "Linked" $linked "Loading" "lazy" "Resources" .Page.Resources "OptimConfig" $optim | partial "plugin/image.html" -}}
    <figcaption class="image-caption">
      {{- .Title | safeHTML -}}
    </figcaption>
  </figure>
{{- else -}}
  {{- $linked := (eq $lightgallery "force") | or ($lightgallery | and (ne .Title "")) -}}
  {{- dict "Page" .Page "Src" .Destination "Alt" .PlainText "Title" .Title "Linked" $linked "Loading" "lazy" "Resources" .Page.Resources "OptimConfig" $optim | partial "plugin/image.html" -}}
{{- end -}}
