2023-05-24 02:47:20 +02:00
|
|
|
{{ if .link }}<a href="{{ .link }}">{{ end }}
|
2023-05-24 02:26:08 +02:00
|
|
|
<figure>
|
2023-05-24 02:47:20 +02:00
|
|
|
<picture>
|
|
|
|
{{ $isJPG := eq (path.Ext .image) ".jpg" }}
|
|
|
|
{{ $isPNG := eq (path.Ext .image) ".png" }}
|
2023-05-24 02:26:08 +02:00
|
|
|
|
2023-05-24 02:47:20 +02:00
|
|
|
{{ if ($isJPG) -}}
|
|
|
|
{{ $webpPath:= replace .image ".jpg" ".webp" }}
|
|
|
|
{{ $webpPathStatic:= printf "static/%s" $webpPath }}
|
2023-05-24 02:26:08 +02:00
|
|
|
|
2023-05-24 02:47:20 +02:00
|
|
|
{{ if (fileExists $webpPathStatic) -}}
|
|
|
|
<source srcset="{{ $webpPath | safeURL }}" type="image/webp">
|
|
|
|
{{- end }}
|
2023-05-24 02:26:08 +02:00
|
|
|
{{- end }}
|
|
|
|
|
2023-05-24 02:47:20 +02:00
|
|
|
{{ if ($isPNG) -}}
|
|
|
|
{{ $webpPath:= replace .image ".png" ".webp" }}
|
|
|
|
{{ $webpPathStatic:= printf "static/%s" $webpPath }}
|
2023-05-24 02:26:08 +02:00
|
|
|
|
2023-05-24 02:47:20 +02:00
|
|
|
{{ if (fileExists $webpPathStatic) -}}
|
|
|
|
<source srcset="{{ $webpPath | safeURL }}" type="image/webp">
|
|
|
|
{{- end }}
|
2023-05-24 02:26:08 +02:00
|
|
|
{{- end }}
|
2023-05-24 02:47:20 +02:00
|
|
|
{{ $img := imageConfig (add "/static" (.image | safeURL)) }}
|
|
|
|
|
2023-06-19 11:00:29 +02:00
|
|
|
<img src="{{ .image | safeURL }}" alt="{{ .alt }}"{{ if not .above_the_fold }} loading="lazy"{{ end }} decoding="async" width="{{ $img.Width }}" height="{{ $img.Height }}">
|
2023-05-24 02:47:20 +02:00
|
|
|
</picture>
|
|
|
|
{{ if .figcaption }}
|
|
|
|
<figcaption>
|
|
|
|
<small><strong>{{ .figcaption }}</strong></small>
|
|
|
|
</figcaption>
|
|
|
|
{{ end }}
|
2023-05-24 02:26:08 +02:00
|
|
|
</figure>
|
2023-05-24 02:47:20 +02:00
|
|
|
{{ if .link }}</a>{{ end }}
|