From f2af0198faa5e819c0043af7c3f0d19e8df5c175 Mon Sep 17 00:00:00 2001 From: stereobooster Date: Wed, 29 Nov 2023 14:51:44 +0100 Subject: [PATCH] fix bug in picture with params --- layouts/_default/_markup/render-image.html | 4 +++- layouts/_default/single.html | 3 ++- layouts/partials/picture.html | 4 ++-- layouts/shortcodes/figure.html | 4 +++- layouts/shortcodes/screenshot.html | 4 +++- 5 files changed, 13 insertions(+), 6 deletions(-) diff --git a/layouts/_default/_markup/render-image.html b/layouts/_default/_markup/render-image.html index 593279b6..aafeb33a 100644 --- a/layouts/_default/_markup/render-image.html +++ b/layouts/_default/_markup/render-image.html @@ -20,7 +20,9 @@
{{- with $img -}} - {{ partial "picture.html" (dict "img" . "alt" $altText "class" $class "x2" $x2) }} + {{ $lazy := $.Page.Site.Params.enableImageLazyLoading | default true }} + {{ $webp := $.Page.Site.Params.enableImageWebp | default true }} + {{ partial "picture.html" (dict "img" . "alt" $altText "class" $class "x2" $x2 "lazy" $lazy "webp" $webp) }} {{- else -}} {{ $altText }} {{- end -}} diff --git a/layouts/_default/single.html b/layouts/_default/single.html index 726dac87..ab7c769a 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -17,7 +17,8 @@
{{ $altText := $.Params.featureAlt | default $.Params.coverAlt | default "" }} {{ $class := "mb-6 -mt-4 rounded-md" }} - {{ partial "picture.html" (dict "img" . "alt" $altText "class" $class "lazy" false) }} + {{ $webp := $.Page.Site.Params.enableImageWebp | default true }} + {{ partial "picture.html" (dict "img" . "alt" $altText "class" $class "lazy" false "webp" $webp) }} {{ with $.Params.coverCaption }}
{{ . | markdownify }}
{{ end }} diff --git a/layouts/partials/picture.html b/layouts/partials/picture.html index 752f84a8..28dfb9ea 100644 --- a/layouts/partials/picture.html +++ b/layouts/partials/picture.html @@ -1,8 +1,8 @@ {{ $img := .img }} {{ $alt := .alt }} {{ $class := .class }} -{{ $lazy := .lazy | default $.Page.Site.Params.enableImageLazyLoading | default true }} -{{ $webp := .webp | default $.Page.Site.Params.enableImageWebp | default true }} +{{ $lazy := .lazy }} +{{ $webp := .webp }} {{ $lqip := .lqip | default false }} {{ $x2 := .x2 | default false }} diff --git a/layouts/shortcodes/figure.html b/layouts/shortcodes/figure.html index 118b7a05..bf5d71bb 100644 --- a/layouts/shortcodes/figure.html +++ b/layouts/shortcodes/figure.html @@ -18,7 +18,9 @@ {{ with $href }}{{ end }} {{- with $img -}} - {{ partial "picture.html" (dict "img" . "alt" $altText "class" $class) }} + {{ $lazy := $.Page.Site.Params.enableImageLazyLoading | default true }} + {{ $webp := $.Page.Site.Params.enableImageWebp | default true }} + {{ partial "picture.html" (dict "img" . "alt" $altText "class" $class "lazy" $lazy "webp" $webp) }} {{- else -}} {{ $altText }} {{- end -}} diff --git a/layouts/shortcodes/screenshot.html b/layouts/shortcodes/screenshot.html index e08243ce..1073488a 100644 --- a/layouts/shortcodes/screenshot.html +++ b/layouts/shortcodes/screenshot.html @@ -12,7 +12,9 @@ {{ $altText = (.Get "caption") | markdownify | plainify }} {{ end }} - {{ partial "picture.html" (dict "img" $image "alt" $altText "x2" true) }} + {{ $lazy := $.Page.Site.Params.enableImageLazyLoading | default true }} + {{ $webp := $.Page.Site.Params.enableImageWebp | default true }} + {{ partial "picture.html" (dict "img" $image "alt" $altText "x2" true "lazy" $lazy "webp" $webp) }} {{- if .Get "href" }}{{ end -}} {{- if .Get "caption" -}}