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
+21 -20
View File
@@ -2,24 +2,25 @@
{{ $alt := .alt }}
{{ $noscriptSupport := .noscript }}
{{ $imgDict := .imgDict }}
{{- if $noscriptSupport -}}
<noscript>
{{ partial "renderer/native" . }}
</noscript>
{{- end -}}
<img
{{- with $imgDict.lqip -}}
{{- $placeholderB64 := .Content | base64Encode -}}
{{- if gt (len $placeholderB64) 2048 }}
src="{{ .Permalink }}"
{{- else }}
src="data:{{ .MediaType }};base64,{{ $placeholderB64 }}"
{{- end }}
data-src="{{ $imgDict.default.Permalink }}"
class="{{ with $class }}{{ . }} {{ end }}blur-up lazyload"
{{ if $noscriptSupport }}<noscript>{{ partial "renderer/native" . }}</noscript>{{ end }}
{{ $base := default "/images/lazyimg" .imageBasePath }}
{{ $defaultURL := path.Join $base (strings.TrimPrefix "/" $imgDict.default.RelPermalink) }}
<img
{{ with $imgDict.lqip -}}
{{ $placeholderB64 := .Content | base64Encode }}
{{ if gt (len $placeholderB64) 2048 }}
{{ $lqipURL := path.Join $base (strings.TrimPrefix "/" .RelPermalink) }}
src="{{ $lqipURL }}"
{{ else }}
src="data:{{ .MediaType }};base64,{{ $placeholderB64 }}"
{{ end }}
data-src="{{ $defaultURL }}"
class="{{ with $class }}{{ . }} {{ end }}blur-up lazyload"
{{ else }}
src="{{ $imgDict.default.Permalink }}" class="{{ $class }} lazyload"
{{- end -}}
{{- with $imgDict.default }} height="{{ .Height }}" width="{{ .Width }}" {{- end -}}
{{- if $imgDict.responsive -}}{{ with partial "renderer/_srcset" $imgDict }} data-sizes="auto" data-srcset="{{ . }}"{{- end }} {{- end -}}
{{- with $alt }} alt="{{ . }}" {{- end }}>
src="{{ $defaultURL }}" class="{{ $class }} lazyload"
{{ 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 }}
{{ with $alt }} alt="{{ . }}" {{ end }}>