use get-image partial

This commit is contained in:
Ben Goldsworthy 2025-06-04 17:57:21 +02:00
parent ed9e769b2d
commit edba5d203e
No known key found for this signature in database
8 changed files with 94 additions and 47 deletions

View file

@ -32,17 +32,14 @@
<article
class="item-tile lazy {{- with .Params.site }}item-tile--{{ . }}{{ end -}}"
{{ if .Params.featured_image }}
style="background-image: url(
{{ with .Resources.GetMatch .Params.featured_image }}
{{ if ( in ( slice "avif" "svg" "gif" ) .MediaType.SubType ) }}
style="background-image: url({{ .RelPermalink }})"
{{ else }}
{{ with .Resize "1000x webp" }}
style="background-image: url({{ .RelPermalink }})"
{{ end }}
{{ end }}
{{ else }}
style="background-image: url({{ .Params.featured_image }})"
{{ end }}
{{- partialCached "images/get-image.html" ( dict "img" . "size" "500x" ) ( printf "%s-500x" .Title ) -}}
{{- else -}}
{{- warnf "Featured image %s is not a page resource" .Params.featured_image -}}
{{- .Params.featured_image -}}
{{- end -}}
)"
{{ end }}
>
{{ if .Params.featured_image -}}
@ -51,15 +48,10 @@
style="display: none;"
src="
{{- with .Resources.GetMatch .Params.featured_image -}}
{{- if ( in ( slice "avif" "svg" "gif" ) .MediaType.SubType ) -}}
{{ .RelPermalink }}
{{- else -}}
{{- with .Resize "1000x webp" -}}
{{- .RelPermalink -}}
{{- end -}}
{{- end -}}
{{- partialCached "images/get-image.html" ( dict "img" . "size" "500x" ) ( printf "%s-500x" .Title ) -}}
{{- else -}}
{{ .Params.featured_image }}
{{- warnf "Featured image %s is not a page resource" .Params.featured_image -}}
{{- .Params.featured_image -}}
{{ end }}
"
alt="