hugo-theme-lowtech/layouts/_default/_markup/render-image.html

18 lines
826 B
HTML

{{/*
S'il n'y a pas de / dans l'url d'une image alors on ajoute le path de l'article
*/}}
{{ $path := cond (in .Destination "/") .Destination (path.Join "/" .Page.File.Dir .Destination) }}
{{ if ne (substr $path -3 3) "svg" }}
{{ $image := .Page.Resources.GetMatch (printf "*%s*" .Destination) }}
{{ with $image }}
{{ $maxWidth := (default "610" site.Params.ImageWidth) }}
{{ if gt $image.Width $maxWidth }}
{{ $resizeParams := delimit (slice (default "610x" site.Params.ImageSize) (default "q100" site.Params.ImageQuality) (default "webp" site.Params.ImageFormat)) " " }}
{{ $resized := $image.Resize (string $resizeParams) }}
{{ $path = $resized.RelPermalink }}
{{ end }}
{{ end }}
{{ end }}
<img src="{{ $path | safeURL }}" alt="{{ .Text }}" {{ with .Title}} title="{{ . }}"{{ end }} loading="lazy" />