<figure>
<picture>
{{- $img := "" -}}
{{ if hasPrefix .Destination "http" }}
{{ $img = resources.GetRemote .Destination }}
{{ else }}
{{ $img = resources.Get .Destination }}
{{end}}
{{- $destination := .Get "src" -}}
{{- $extension := path.Ext $destination -}}
{{- $resources := .Page.Resources -}}
{{- $avifPath:= replace $destination $extension ".avif" -}}
{{- $webpPath:= replace $destination $extension ".webp" -}}
{{- $altText := .Get "alt" -}}
{{- with $resources.GetMatch $avifPath -}}
<source srcset="{{- $avifPath -}}" type="image/avif">
{{- end -}}
{{- with $resources.GetMatch $webpPath -}}
<source srcset="{{- $webpPath -}}" type="image/webp">
{{- end -}}
{{- with $resources.GetMatch $destination -}}
<img
src="{{- .Permalink -}}"
alt="{{- $altText -}}"
loading="lazy"
decoding="async"
width="{{- .Width -}}"
height="{{- .Height -}}"
/>
{{- end -}}
</picture>
<figcaption>{{ .Get "caption" }}</figcaption>
</figure>
the error is:
/layouts/_default/_markup/render-image.html:9:24": execute of template failed: template: _default/_markup/render-image.html:9:24: executing "_default/_markup/render-image.html" at <.Get>: can't evaluate field Get in type goldmark.linkContext
my intention is, if there are webp or avif, get it
Thank u very much