1

Optimisation des images++

This commit is contained in:
2026-03-06 00:16:17 +01:00
parent 1a341d428e
commit d7064aacbb
7 changed files with 11 additions and 9 deletions

View File

@@ -100,7 +100,7 @@
{{- $title := default (printf "Image complémentaire : %s" $imageName) (index $data "title") -}} {{- $title := default (printf "Image complémentaire : %s" $imageName) (index $data "title") -}}
{{- $thumbnail := . -}} {{- $thumbnail := . -}}
{{- if and (ne .MediaType.SubType "svg") (gt .Width 360) -}} {{- if and (ne .MediaType.SubType "svg") (gt .Width 360) -}}
{{- $thumbnail = .Resize "360x" -}} {{- $thumbnail = .Resize "360x webp q80" -}}
{{- end -}} {{- end -}}
<li> <li>
<a href="{{ .RelPermalink }}" title="{{ $title }}"> <a href="{{ .RelPermalink }}" title="{{ $title }}">

View File

@@ -41,6 +41,8 @@
{{- $thumbnailTransform = "900x506" -}} {{- $thumbnailTransform = "900x506" -}}
{{- end -}} {{- end -}}
{{- $thumbnailOptions := printf "%s webp q80" $thumbnailTransform -}}
{{- $coverPath := $page.Params.cover -}} {{- $coverPath := $page.Params.cover -}}
{{- $image := false -}} {{- $image := false -}}
{{- if $coverPath -}} {{- if $coverPath -}}
@@ -109,7 +111,7 @@
<a href="{{ $page.RelPermalink }}"> <a href="{{ $page.RelPermalink }}">
<figure> <figure>
{{- with $image -}} {{- with $image -}}
{{- $resized := .Fill $thumbnailTransform -}} {{- $resized := .Fill $thumbnailOptions -}}
<img src="{{ $resized.RelPermalink }}" alt="Image de couverture pour {{ $page.Title }}" loading="lazy"> <img src="{{ $resized.RelPermalink }}" alt="Image de couverture pour {{ $page.Title }}" loading="lazy">
{{- end -}} {{- end -}}
</figure> </figure>
@@ -125,7 +127,7 @@
<a href="{{ $page.RelPermalink }}"> <a href="{{ $page.RelPermalink }}">
<figure> <figure>
{{- with $image -}} {{- with $image -}}
{{- $resized := .Fill $thumbnailTransform -}} {{- $resized := .Fill $thumbnailOptions -}}
<img src="{{ $resized.RelPermalink }}" alt="Image de couverture pour {{ $page.Title }}" loading="lazy"> <img src="{{ $resized.RelPermalink }}" alt="Image de couverture pour {{ $page.Title }}" loading="lazy">
{{- end -}} {{- end -}}
</figure> </figure>

View File

@@ -4,7 +4,7 @@
{{- $assetPath := "images/oeuvres/l-anankeisme.png" -}} {{- $assetPath := "images/oeuvres/l-anankeisme.png" -}}
{{- $source := resources.Get $assetPath -}} {{- $source := resources.Get $assetPath -}}
{{- if $source -}} {{- if $source -}}
{{- $img := $source.Resize "320x" -}} {{- $img := $source.Resize "320x webp q80" -}}
<img src="{{ $img.RelPermalink }}" width="{{ $img.Width }}" height="{{ $img.Height }}" alt="Couverture de L'Anankéisme" loading="lazy"> <img src="{{ $img.RelPermalink }}" width="{{ $img.Width }}" height="{{ $img.Height }}" alt="Couverture de L'Anankéisme" loading="lazy">
{{- end -}} {{- end -}}
</figure> </figure>

View File

@@ -4,7 +4,7 @@
{{- $assetPath := "images/oeuvres/l-humain-cette-espece-primitive.jpeg" -}} {{- $assetPath := "images/oeuvres/l-humain-cette-espece-primitive.jpeg" -}}
{{- $source := resources.Get $assetPath -}} {{- $source := resources.Get $assetPath -}}
{{- if $source -}} {{- if $source -}}
{{- $img := $source.Resize "320x" -}} {{- $img := $source.Resize "320x webp q80" -}}
<img src="{{ $img.RelPermalink }}" width="{{ $img.Width }}" height="{{ $img.Height }}" alt="Couverture de L'Humain, cette espèce primitive" loading="lazy"> <img src="{{ $img.RelPermalink }}" width="{{ $img.Width }}" height="{{ $img.Height }}" alt="Couverture de L'Humain, cette espèce primitive" loading="lazy">
{{- end -}} {{- end -}}
</figure> </figure>

View File

@@ -6,7 +6,7 @@
{{- $logo := resources.GetMatch $logoPath -}} {{- $logo := resources.GetMatch $logoPath -}}
<a href="{{ "/" | relURL }}" aria-label="Revenir à l'accueil"> <a href="{{ "/" | relURL }}" aria-label="Revenir à l'accueil">
{{- with $logo -}} {{- with $logo -}}
{{- $resized := .Resize "64x" -}} {{- $resized := .Resize "64x webp q80" -}}
<img src="{{ $resized.RelPermalink }}" alt=""> <img src="{{ $resized.RelPermalink }}" alt="">
{{- end -}} {{- end -}}
<strong>{{ $site.Title }}</strong> <strong>{{ $site.Title }}</strong>

View File

@@ -36,7 +36,7 @@
{{- with $image -}} {{- with $image -}}
<a href="{{ $page.RelPermalink }}"> <a href="{{ $page.RelPermalink }}">
<figure> <figure>
{{- $resized := .Fill "600x340" -}} {{- $resized := .Fill "600x340 webp q80" -}}
<img src="{{ $resized.RelPermalink }}" alt="Image de couverture pour {{ $page.Title }}" loading="lazy"> <img src="{{ $resized.RelPermalink }}" alt="Image de couverture pour {{ $page.Title }}" loading="lazy">
</figure> </figure>
</a> </a>

View File

@@ -305,7 +305,7 @@
<a href="{{ $page.RelPermalink }}"> <a href="{{ $page.RelPermalink }}">
<figure> <figure>
{{- with $image -}} {{- with $image -}}
{{- $resized := .Fill "166x91" -}} {{- $resized := .Fill "166x91 webp q80" -}}
<img src="{{ $resized.RelPermalink }}" alt="Capture du lien {{ $page.Title }}" loading="lazy"> <img src="{{ $resized.RelPermalink }}" alt="Capture du lien {{ $page.Title }}" loading="lazy">
{{- end -}} {{- end -}}
</figure> </figure>
@@ -391,7 +391,7 @@
<a href="{{ $item.RelPermalink }}" title="{{ $item.Title }}"> <a href="{{ $item.RelPermalink }}" title="{{ $item.Title }}">
<figure> <figure>
{{- with $itemImage -}} {{- with $itemImage -}}
{{- $resized := .Resize "x128" -}} {{- $resized := .Resize "x128 webp q80" -}}
<img src="{{ $resized.RelPermalink }}" alt="{{ $item.Title }}" title="{{ $item.Title }}" loading="lazy"> <img src="{{ $resized.RelPermalink }}" alt="{{ $item.Title }}" title="{{ $item.Title }}" loading="lazy">
{{- end -}} {{- end -}}
</figure> </figure>