From 3b16978dc1c87cf8a47ac54f765b97b762de473d Mon Sep 17 00:00:00 2001 From: Olivia206 <olivia.simonet@mmibordeaux.com> Date: Wed, 14 Feb 2024 12:09:44 +0100 Subject: [PATCH] use conditions and types in image-default --- .../blocks/templates/posts/large.html | 12 +++++------ layouts/partials/commons/image-default.html | 20 +++++++++++++++---- layouts/partials/events/event.html | 11 +++++----- layouts/partials/posts/post.html | 6 +++--- 4 files changed, 30 insertions(+), 19 deletions(-) diff --git a/layouts/partials/blocks/templates/posts/large.html b/layouts/partials/blocks/templates/posts/large.html index a67729c6..3dbe90b4 100644 --- a/layouts/partials/blocks/templates/posts/large.html +++ b/layouts/partials/blocks/templates/posts/large.html @@ -52,12 +52,12 @@ <div class="media"> {{- if .Params.image -}} {{- partial "commons/image.html" - (dict - "image" .Params.image - "sizes" site.Params.image_sizes.sections.posts.item - ) -}} - {{- else if site.Data.website.default_image -}} - {{- partial "commons/image-default.html" -}} + (dict + "image" .Params.image + "sizes" site.Params.image_sizes.sections.events.item + ) -}} + {{- else -}} + {{- partial "commons/image-default.html" (dict "type" "posts") -}} {{- end -}} </div> </article> diff --git a/layouts/partials/commons/image-default.html b/layouts/partials/commons/image-default.html index c8417e21..6bf324e7 100644 --- a/layouts/partials/commons/image-default.html +++ b/layouts/partials/commons/image-default.html @@ -1,4 +1,16 @@ -{{- partial "commons/image.html" - (dict - "image" site.Data.website.default_image - ) -}} \ No newline at end of file +{{ if and site.Params.events.default_image site.Data.website.default_image }} + + {{ $type := .type}} + {{ $image := site.Data.website.default_image }} + + {{ with index site.Params.image_sizes.sections $type }} + {{ $sizes := .items }} + + {{- partial "commons/image.html" + (dict + "image" $image + "sizes" $sizes + ) -}} + {{ end }} + +{{ end }} \ No newline at end of file diff --git a/layouts/partials/events/event.html b/layouts/partials/events/event.html index 3ebae0c5..57eb5a97 100644 --- a/layouts/partials/events/event.html +++ b/layouts/partials/events/event.html @@ -83,16 +83,15 @@ {{ end }} </div> <div class="media"> - {{- $event_image := cond (isset .Params "image") .Params.image ( and (.Site.Params.events.default_image) (site.Data.website.default_image)) -}} - {{- if $event_image -}} + {{- if .Params.image -}} {{- partial "commons/image.html" (dict - "image" $event_image + "image" .Params.image "sizes" site.Params.image_sizes.sections.events.item ) -}} - {{/* {{- else if site.Data.website.default_image -}} - {{- partial "commons/image-default.html" -}} */}} - {{- end -}} + {{- else -}} + {{- partial "commons/image-default.html" (dict "type" "events") -}} + {{- end -}} </div> </article> {{ end }} \ No newline at end of file diff --git a/layouts/partials/posts/post.html b/layouts/partials/posts/post.html index 449df4a7..352d7d88 100644 --- a/layouts/partials/posts/post.html +++ b/layouts/partials/posts/post.html @@ -53,10 +53,10 @@ {{- partial "commons/image.html" (dict "image" .Params.image - "sizes" site.Params.image_sizes.sections.posts.item + "sizes" site.Params.image_sizes.sections.events.item ) -}} - {{- else if site.Data.website.default_image -}} - {{- partial "commons/image-default.html" -}} + {{- else -}} + {{- partial "commons/image-default.html" (dict "type" "posts") -}} {{- end -}} </div> </article> -- GitLab