add base image location

This commit is contained in:
2025-08-23 22:54:08 -02:30
parent 72183e14a3
commit adb7e7ac3f
9 changed files with 69 additions and 58 deletions
+5 -4
View File
@@ -1,8 +1,9 @@
{{/* Input: Input: dict {"responsive": [RESOURCE, ...]}. Output: srcset string */}}
{{/* Input: dict {"responsive": [RESOURCE, ...], "imageBasePath": "/images/lazyimg"} */}}
{{ $images := .responsive }}
{{ $base := default "/images/lazyimg" .imageBasePath }}
{{ $srcset := slice }}
{{ range $images }}
{{ $srcset = append (printf "%s %dw" .Permalink .Width) $srcset }}
{{ $u := path.Join $base (strings.TrimPrefix "/" .RelPermalink) }}
{{ $srcset = append (printf "%s %dw" $u .Width) $srcset }}
{{ end }}
{{ return (delimit $srcset ",\n") }}
{{ return (delimit $srcset ",\n") }}