From 73f3b580038a2b78b98c63d708abb2e551a4641b Mon Sep 17 00:00:00 2001 From: Richard Dern Date: Mon, 23 Mar 2026 23:13:12 +0100 Subject: [PATCH] =?UTF-8?q?Recadre=20les=20images=20verticales=20du=20th?= =?UTF-8?q?=C3=A8me=202026?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../layouts/_partials/media/display-img.html | 23 +++++++++++++------ .../_partials/media/process-image.html | 2 ++ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/themes/2026/layouts/_partials/media/display-img.html b/themes/2026/layouts/_partials/media/display-img.html index 3b7cd029..1016c378 100644 --- a/themes/2026/layouts/_partials/media/display-img.html +++ b/themes/2026/layouts/_partials/media/display-img.html @@ -6,27 +6,36 @@ {{- $display := $image -}} {{- if ne $image.MediaType.SubType "svg" -}} - {{- if gt $image.Width $image.Height -}} + {{- if and (gt $image.Height $image.Width) (ge $image.Height 1080) -}} + {{- $cropHeight := div (mul $image.Width 9) 16 -}} + {{- $display = partial "media/process-image.html" (dict + "image" $image + "action" "Crop" + "spec" (printf "%dx%d TopLeft" $image.Width $cropHeight) + ) -}} + {{- end -}} + + {{- if gt $display.Width $display.Height -}} {{- $maxWidth := 1400 -}} {{- if and $showMeta (not $forceCentered) -}} {{- $maxWidth = 900 -}} {{- end -}} - {{- $targetWidth := $image.Width -}} - {{- if gt $image.Width $maxWidth -}} + {{- $targetWidth := $display.Width -}} + {{- if gt $display.Width $maxWidth -}} {{- $targetWidth = $maxWidth -}} {{- end -}} {{- $display = partial "media/process-image.html" (dict - "image" $image + "image" $display "action" "Resize" "spec" (printf "%dx" $targetWidth) ) -}} {{- else -}} - {{- $targetHeight := $image.Height -}} - {{- if gt $image.Height 900 -}} + {{- $targetHeight := $display.Height -}} + {{- if gt $display.Height 900 -}} {{- $targetHeight = 900 -}} {{- end -}} {{- $display = partial "media/process-image.html" (dict - "image" $image + "image" $display "action" "Resize" "spec" (printf "x%d" $targetHeight) ) -}} diff --git a/themes/2026/layouts/_partials/media/process-image.html b/themes/2026/layouts/_partials/media/process-image.html index d12eb461..25312609 100644 --- a/themes/2026/layouts/_partials/media/process-image.html +++ b/themes/2026/layouts/_partials/media/process-image.html @@ -20,6 +20,8 @@ {{- $options := printf "%s webp q80" $spec -}} {{- if eq $action "Fill" -}} {{- $result = $image.Fill $options -}} + {{- else if eq $action "Crop" -}} + {{- $result = $image.Crop $options -}} {{- else if eq $action "Resize" -}} {{- $result = $image.Resize $options -}} {{- else -}}