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 -}}