1

Recadre les images verticales du thème 2026

This commit is contained in:
2026-03-23 23:13:12 +01:00
parent 99f674dd9f
commit 73f3b58003
2 changed files with 18 additions and 7 deletions

View File

@@ -6,27 +6,36 @@
{{- $display := $image -}} {{- $display := $image -}}
{{- if ne $image.MediaType.SubType "svg" -}} {{- 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 -}} {{- $maxWidth := 1400 -}}
{{- if and $showMeta (not $forceCentered) -}} {{- if and $showMeta (not $forceCentered) -}}
{{- $maxWidth = 900 -}} {{- $maxWidth = 900 -}}
{{- end -}} {{- end -}}
{{- $targetWidth := $image.Width -}} {{- $targetWidth := $display.Width -}}
{{- if gt $image.Width $maxWidth -}} {{- if gt $display.Width $maxWidth -}}
{{- $targetWidth = $maxWidth -}} {{- $targetWidth = $maxWidth -}}
{{- end -}} {{- end -}}
{{- $display = partial "media/process-image.html" (dict {{- $display = partial "media/process-image.html" (dict
"image" $image "image" $display
"action" "Resize" "action" "Resize"
"spec" (printf "%dx" $targetWidth) "spec" (printf "%dx" $targetWidth)
) -}} ) -}}
{{- else -}} {{- else -}}
{{- $targetHeight := $image.Height -}} {{- $targetHeight := $display.Height -}}
{{- if gt $image.Height 900 -}} {{- if gt $display.Height 900 -}}
{{- $targetHeight = 900 -}} {{- $targetHeight = 900 -}}
{{- end -}} {{- end -}}
{{- $display = partial "media/process-image.html" (dict {{- $display = partial "media/process-image.html" (dict
"image" $image "image" $display
"action" "Resize" "action" "Resize"
"spec" (printf "x%d" $targetHeight) "spec" (printf "x%d" $targetHeight)
) -}} ) -}}

View File

@@ -20,6 +20,8 @@
{{- $options := printf "%s webp q80" $spec -}} {{- $options := printf "%s webp q80" $spec -}}
{{- if eq $action "Fill" -}} {{- if eq $action "Fill" -}}
{{- $result = $image.Fill $options -}} {{- $result = $image.Fill $options -}}
{{- else if eq $action "Crop" -}}
{{- $result = $image.Crop $options -}}
{{- else if eq $action "Resize" -}} {{- else if eq $action "Resize" -}}
{{- $result = $image.Resize $options -}} {{- $result = $image.Resize $options -}}
{{- else -}} {{- else -}}