2023-05-24 02:26:08 +02:00
|
|
|
<picture>
|
|
|
|
{{ $isJPG := eq (path.Ext .Destination) ".jpg" }}
|
|
|
|
{{ $isPNG := eq (path.Ext .Destination) ".png" }}
|
2023-05-05 16:36:10 +02:00
|
|
|
|
2023-05-24 02:26:08 +02:00
|
|
|
{{ if ($isJPG) -}}
|
|
|
|
{{ $webpPath:= replace .Destination ".jpg" ".webp" }}
|
|
|
|
{{ $webpPathStatic:= printf "static/%s" $webpPath }}
|
|
|
|
|
|
|
|
{{ if (fileExists $webpPathStatic) -}}
|
|
|
|
<source srcset="{{ $webpPath | safeURL }}" type="image/webp" >
|
|
|
|
{{- end }}
|
|
|
|
{{- end }}
|
|
|
|
|
|
|
|
{{ if ($isPNG) -}}
|
|
|
|
{{ $webpPath:= replace .Destination ".png" ".webp" }}
|
|
|
|
{{ $webpPathStatic:= printf "static/%s" $webpPath }}
|
|
|
|
|
|
|
|
{{ if (fileExists $webpPathStatic) -}}
|
|
|
|
<source srcset="{{ $webpPath | safeURL }}" type="image/webp" >
|
|
|
|
{{- end }}
|
|
|
|
{{- end }}
|
|
|
|
|
|
|
|
{{- $img := .Page.Resources.GetMatch .Destination -}}
|
|
|
|
{{- if and (not $img) .Page.File -}}
|
|
|
|
{{ $path := path.Join .Page.File.Dir .Destination }}
|
|
|
|
{{- $img = resources.Get $path -}}
|
|
|
|
{{- end -}}
|
|
|
|
<img
|
|
|
|
src="{{ .Destination | safeURL }}"
|
|
|
|
alt="{{ .Text }}"
|
|
|
|
loading="lazy"
|
|
|
|
decoding="async"
|
|
|
|
width="{{ $img.Width }}"
|
|
|
|
height="{{ $img.Height }}"
|
|
|
|
/>
|
|
|
|
</picture>
|