{{- /* Markdown images inside a page bundle get resized and lazy-loaded.
       External or non-resource images are passed through unchanged. */ -}}
{{- $src := .Destination -}}
{{- $alt := .Text | plainify -}}
{{- $caption := .Title -}}
{{- with .Page.Resources.GetMatch $src -}}
  {{- $img := . -}}
  {{- if gt .Width 1200 -}}{{- $img = .Resize "1200x webp q82" -}}{{- end -}}
  <figure class="content-figure">
    <a href="{{ .RelPermalink }}">
      <img src="{{ $img.RelPermalink }}" width="{{ $img.Width }}" height="{{ $img.Height }}"
           alt="{{ $alt }}" loading="lazy" decoding="async">
    </a>
    {{- with $caption }}<figcaption>{{ . }}</figcaption>{{ end -}}
  </figure>
{{- else -}}
  <img src="{{ $src | safeURL }}" alt="{{ $alt }}" loading="lazy" decoding="async">
{{- end -}}
