diff --git a/themes/2026/layouts/_partials/article-header.html b/themes/2026/layouts/_partials/article-header.html index 3697320a..0915fe4b 100644 --- a/themes/2026/layouts/_partials/article-header.html +++ b/themes/2026/layouts/_partials/article-header.html @@ -76,7 +76,11 @@ {{- if gt $coverDisplay.Width 1480 -}} {{- $coverWidth = 1480 -}} {{- end -}} - {{- $coverDisplay = $coverImage.Resize (printf "%dx webp q80" $coverWidth) -}} + {{- $coverDisplay = partial "media/process-image.html" (dict + "image" $coverImage + "action" "Resize" + "spec" (printf "%dx" $coverWidth) + ) -}} {{- end -}} {{- end -}} {{- end -}} diff --git a/themes/2026/layouts/_partials/asides/complementary-images.html b/themes/2026/layouts/_partials/asides/complementary-images.html index 5be2e072..eea06487 100644 --- a/themes/2026/layouts/_partials/asides/complementary-images.html +++ b/themes/2026/layouts/_partials/asides/complementary-images.html @@ -100,7 +100,11 @@ {{- $title := default (printf "Image complémentaire : %s" $imageName) (index $data "title") -}} {{- $thumbnail := . -}} {{- if and (ne .MediaType.SubType "svg") (gt .Width 360) -}} - {{- $thumbnail = .Resize "360x webp q80" -}} + {{- $thumbnail = partial "media/process-image.html" (dict + "image" . + "action" "Resize" + "spec" "360x" + ) -}} {{- end -}}
  • diff --git a/themes/2026/layouts/_partials/card.html b/themes/2026/layouts/_partials/card.html index 6fbf5759..c7c2690f 100644 --- a/themes/2026/layouts/_partials/card.html +++ b/themes/2026/layouts/_partials/card.html @@ -41,8 +41,6 @@ {{- $thumbnailTransform = "900x506" -}} {{- end -}} -{{- $thumbnailOptions := printf "%s webp q80" $thumbnailTransform -}} - {{- $coverPath := $page.Params.cover -}} {{- $image := false -}} {{- if $coverPath -}} @@ -111,7 +109,11 @@
    {{- with $image -}} - {{- $resized := .Fill $thumbnailOptions -}} + {{- $resized := partial "media/process-image.html" (dict + "image" . + "action" "Fill" + "spec" $thumbnailTransform + ) -}} Image de couverture pour {{ $page.Title }} {{- end -}}
    @@ -127,7 +129,11 @@
    {{- with $image -}} - {{- $resized := .Fill $thumbnailOptions -}} + {{- $resized := partial "media/process-image.html" (dict + "image" . + "action" "Fill" + "spec" $thumbnailTransform + ) -}} Image de couverture pour {{ $page.Title }} {{- end -}}
    diff --git a/themes/2026/layouts/_partials/media/display-img.html b/themes/2026/layouts/_partials/media/display-img.html index 95d920f3..3b7cd029 100644 --- a/themes/2026/layouts/_partials/media/display-img.html +++ b/themes/2026/layouts/_partials/media/display-img.html @@ -15,13 +15,21 @@ {{- if gt $image.Width $maxWidth -}} {{- $targetWidth = $maxWidth -}} {{- end -}} - {{- $display = $image.Resize (printf "%dx webp q80" $targetWidth) -}} + {{- $display = partial "media/process-image.html" (dict + "image" $image + "action" "Resize" + "spec" (printf "%dx" $targetWidth) + ) -}} {{- else -}} {{- $targetHeight := $image.Height -}} {{- if gt $image.Height 900 -}} {{- $targetHeight = 900 -}} {{- end -}} - {{- $display = $image.Resize (printf "x%d webp q80" $targetHeight) -}} + {{- $display = partial "media/process-image.html" (dict + "image" $image + "action" "Resize" + "spec" (printf "x%d" $targetHeight) + ) -}} {{- end -}} {{- end -}} diff --git a/themes/2026/layouts/_partials/media/process-image.html b/themes/2026/layouts/_partials/media/process-image.html new file mode 100644 index 00000000..d12eb461 --- /dev/null +++ b/themes/2026/layouts/_partials/media/process-image.html @@ -0,0 +1,30 @@ +{{/* Préserve les GIF animés en évitant toute transformation Hugo. */}} +{{- $image := .image -}} +{{- if not $image -}} + {{- errorf "media/process-image.html: missing image resource" -}} +{{- end -}} + +{{- $action := .action -}} +{{- if not $action -}} + {{- errorf "media/process-image.html: missing image action for %q" $image.Name -}} +{{- end -}} + +{{- $spec := .spec -}} +{{- if not $spec -}} + {{- errorf "media/process-image.html: missing image spec for %q" $image.Name -}} +{{- end -}} + +{{- $result := $image -}} +{{- $subType := lower $image.MediaType.SubType -}} +{{- if and (ne $subType "svg") (ne $subType "gif") -}} + {{- $options := printf "%s webp q80" $spec -}} + {{- if eq $action "Fill" -}} + {{- $result = $image.Fill $options -}} + {{- else if eq $action "Resize" -}} + {{- $result = $image.Resize $options -}} + {{- else -}} + {{- errorf "media/process-image.html: unsupported image action %q for %q" $action $image.Name -}} + {{- end -}} +{{- end -}} + +{{- return $result -}} diff --git a/themes/2026/layouts/_partials/oeuvres/l-anankeisme.html b/themes/2026/layouts/_partials/oeuvres/l-anankeisme.html index 53eebfea..9fccdfb4 100644 --- a/themes/2026/layouts/_partials/oeuvres/l-anankeisme.html +++ b/themes/2026/layouts/_partials/oeuvres/l-anankeisme.html @@ -4,7 +4,11 @@ {{- $assetPath := "images/oeuvres/l-anankeisme.png" -}} {{- $source := resources.Get $assetPath -}} {{- if $source -}} - {{- $img := $source.Resize "320x webp q80" -}} + {{- $img := partial "media/process-image.html" (dict + "image" $source + "action" "Resize" + "spec" "320x" + ) -}} Couverture de L'Anankéisme {{- end -}} diff --git a/themes/2026/layouts/_partials/oeuvres/l-humain-cette-espece-primitive.html b/themes/2026/layouts/_partials/oeuvres/l-humain-cette-espece-primitive.html index c9510655..06a3503f 100644 --- a/themes/2026/layouts/_partials/oeuvres/l-humain-cette-espece-primitive.html +++ b/themes/2026/layouts/_partials/oeuvres/l-humain-cette-espece-primitive.html @@ -4,7 +4,11 @@ {{- $assetPath := "images/oeuvres/l-humain-cette-espece-primitive.jpeg" -}} {{- $source := resources.Get $assetPath -}} {{- if $source -}} - {{- $img := $source.Resize "320x webp q80" -}} + {{- $img := partial "media/process-image.html" (dict + "image" $source + "action" "Resize" + "spec" "320x" + ) -}} Couverture de L'Humain, cette espèce primitive {{- end -}} diff --git a/themes/2026/layouts/_partials/site-title.html b/themes/2026/layouts/_partials/site-title.html index e8717c48..cab12416 100644 --- a/themes/2026/layouts/_partials/site-title.html +++ b/themes/2026/layouts/_partials/site-title.html @@ -6,7 +6,11 @@ {{- $logo := resources.GetMatch $logoPath -}}
    {{- with $logo -}} - {{- $resized := .Resize "64x webp q80" -}} + {{- $resized := partial "media/process-image.html" (dict + "image" . + "action" "Resize" + "spec" "64x" + ) -}} {{- end -}} {{ $site.Title }} diff --git a/themes/2026/layouts/_partials/timeline-list.html b/themes/2026/layouts/_partials/timeline-list.html index b8770f56..35104eb5 100644 --- a/themes/2026/layouts/_partials/timeline-list.html +++ b/themes/2026/layouts/_partials/timeline-list.html @@ -36,7 +36,11 @@ {{- with $image -}}
    - {{- $resized := .Fill "600x340 webp q80" -}} + {{- $resized := partial "media/process-image.html" (dict + "image" . + "action" "Fill" + "spec" "600x340" + ) -}} Image de couverture pour {{ $page.Title }}
    diff --git a/themes/2026/layouts/home.html b/themes/2026/layouts/home.html index ac4f8fe7..b80da435 100644 --- a/themes/2026/layouts/home.html +++ b/themes/2026/layouts/home.html @@ -315,7 +315,11 @@
    {{- with $image -}} - {{- $resized := .Fill "166x91 webp q80" -}} + {{- $resized := partial "media/process-image.html" (dict + "image" . + "action" "Fill" + "spec" "166x91" + ) -}} Capture du lien {{ $page.Title }} {{- end -}}
    @@ -401,7 +405,11 @@
    {{- with $itemImage -}} - {{- $resized := .Resize "x128 webp q80" -}} + {{- $resized := partial "media/process-image.html" (dict + "image" . + "action" "Resize" + "spec" "x128" + ) -}} {{ $item.Title }} {{- end -}}