Well, I backtracked… I just said in the last post that I wasn’t going to provide fallback images for the old browsers , and now it’s here…

{{ $pathArr := split .Destination "." }}
{{ $srcBase := index $pathArr 0 }}

{{ if .Title }}
  <figure>
    {{ if (strings.HasSuffix .Destination ".svg") }}
    <img src="{{ .Destination | safeURL }}" alt="{{ .Text }}">
    {{ else }}
    <picture>
      <source srcset="{{ $srcBase }}.webp" type="image/webp">
      <img src="{{ .Destination | safeURL }}" alt="{{ .Text }}">
    </picture>
    {{ end }}
    <figcaption>{{ .Title }}</figcaption>
  </figure>
{{ else }}
  {{ if (strings.HasSuffix .Destination ".svg") }}
    <img src="{{ .Destination | safeURL }}" alt="{{ .Text }}">
  {{ else }}
    <picture>
      <source srcset="{{ $srcBase }}.webp" type="image/webp">
      <img src="{{ .Destination | safeURL }}" alt="{{ .Text }}">
    </picture>
  {{ end }}
{{ end }}