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
+15 -13
View File
@@ -3,17 +3,19 @@
{{ $imgDict := .imgDict }}
{{ $imgDictFallback := .imgDictFallback }}
{{ $base := default "/images/lazyimg" .imageBasePath }}
<picture>
<source type="image/webp"
{{- with $imgDict.lqip -}}
{{- $placeholderB64 := .Content | base64Encode -}}
{{- if gt (len $placeholderB64) 2048 }}
srcset="{{ .Permalink }}"
{{- else }}
srcset="data:{{ .MediaType }};base64,{{ $placeholderB64 }}"
{{- end }}
{{- end -}}
{{- with $imgDict.default }} height="{{ .Height }}" width="{{ .Width }}" {{- end -}}
{{- if $imgDict.responsive -}}{{ with partial "renderer/_srcset" $imgDict }} data-sizes="auto" data-srcset="{{ . }}"{{- end }} {{- end -}}>
{{ partial "renderer/lqip" (merge . (dict "imgDict" $imgDictFallback)) }}
</picture>
<source type="image/webp"
{{ with $imgDict.lqip -}}
{{ $placeholderB64 := .Content | base64Encode }}
{{ if gt (len $placeholderB64) 2048 }}
{{ $lqipURL := path.Join $base (strings.TrimPrefix "/" .RelPermalink) }}
srcset="{{ $lqipURL }}"
{{ else }}
srcset="data:{{ .MediaType }};base64,{{ $placeholderB64 }}"
{{ end }}
{{- end }}
{{ with $imgDict.default }} height="{{ .Height }}" width="{{ .Width }}" {{ end }}
{{ if $imgDict.responsive }}{{ with partial "renderer/_srcset" (merge $imgDict (dict "imageBasePath" $base)) }} data-sizes="auto" data-srcset="{{ . }}"{{ end }}{{ end }}>
{{ partial "renderer/lqip" (merge . (dict "imgDict" $imgDictFallback "imageBasePath" $base)) }}
</picture>