feat: Add new parameters on hugo to fix resize image

This commit is contained in:
Simon 2022-02-01 12:12:02 +01:00
parent 2b026a00ab
commit ae3473dcea
1 changed files with 2 additions and 1 deletions

View File

@ -4,7 +4,8 @@
{{ $path := cond (in .Destination "/") .Destination (path.Join "/" .Page.File.Dir .Destination) }}
{{ $image := .Page.Resources.GetMatch (printf "*%s*" .Destination) }}
{{ with $image }}
{{ $resized := $image.Resize "610x q100 webp" }}
{{ $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 }}
<img src="{{ $path | safeURL }}" alt="{{ .Text }}" {{ with .Title}} title="{{ . }}"{{ end }} loading="lazy" />