From bfb5677cd15d85f879e261227b066736e7854e92 Mon Sep 17 00:00:00 2001 From: MoritzWeber Date: Sun, 13 Jul 2025 18:56:34 +0200 Subject: [PATCH] feat: Use human readable format for different image sizes --- layouts/partials/image.html | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/layouts/partials/image.html b/layouts/partials/image.html index 58b38ed8..90b595f4 100644 --- a/layouts/partials/image.html +++ b/layouts/partials/image.html @@ -10,6 +10,9 @@ {{ end }} {{ end }} +{{- $name := $image.RelPermalink | strings.TrimSuffix (printf ".%s" $image.MediaType.SubType) -}} +{{- $extension := $image.MediaType.SubType -}} + {{- $widths := slice -}} {{- if gt $image.Width 2200 -}} @@ -30,7 +33,7 @@ {{- $srcset := slice -}} {{- range $i, $width := $widths -}} - {{- with $image.Resize (printf "%dx" $width) -}} + {{- with $image.Resize (printf "%dx" $width) | resources.Copy (print $name "_" $width "." $extension) -}} {{- $srcset = $srcset | append (printf "%s %dw" .RelPermalink $width) -}} {{- end -}} {{- end -}}