cremeaux/layouts/_default/_markup/render-image.html

12 lines
563 B
HTML
Raw Permalink Normal View History

2020-11-09 12:36:28 +01:00
{{/*
S'il n'y a pas de / dans l'url d'une image alors on ajoute le path de l'article
*/}}
2021-06-20 22:19:59 +02:00
{{ $path := cond (in .Destination "/") .Destination (path.Join "/" .Page.File.Dir .Destination) }}
{{ $image := .Page.Resources.GetMatch (printf "*%s*" .Destination) }}
{{ with $image }}
2023-05-04 16:53:38 +02:00
{{ $width := cond (gt .Width 960) 960 .Width }}
{{ $resized := $image.Resize (printf "%sx q100 webp" (string $width)) }}
2021-06-20 22:19:59 +02:00
{{ $path = $resized.RelPermalink }}
{{ end }}
<img src="{{ $path | safeURL }}" alt="{{ .Text }}" {{ with .Title}} title="{{ . }}"{{ end }} loading="lazy" />