Accessibility: add alt text for big hero

This commit is contained in:
Nicolas Lorin 2023-03-11 11:04:40 +01:00
parent 6af086dd65
commit b00813ad26
No known key found for this signature in database
GPG key ID: BDE9D4146DB38124

View file

@ -3,14 +3,16 @@
{{- $images := .Resources.ByType "image" -}} {{- $images := .Resources.ByType "image" -}}
{{- $featured := $images.GetMatch "*feature*" -}} {{- $featured := $images.GetMatch "*feature*" -}}
{{- if not $featured }}{{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }}{{ end -}} {{- if not $featured }}{{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }}{{ end -}}
{{- $alt := .Page.Title -}}
{{- with .Page.Params.alt }}{{ $alt = . }}{{ end -}}
{{- with $featured -}} {{- with $featured -}}
{{ if $disableImageOptimization }} {{ if $disableImageOptimization }}
{{ with . }} {{ with . }}
<img class="w-full rounded-lg single_hero_round nozoom" width="{{ .Width }}" height="{{ .Height }}" src="{{ .RelPermalink }}"> <img class="w-full rounded-lg single_hero_round nozoom" alt="{{ $alt }}" width="{{ .Width }}" height="{{ .Height }}" src="{{ .RelPermalink }}">
{{ end }} {{ end }}
{{ else }} {{ else }}
{{ with .Resize "1200x" }} {{ with .Resize "1200x" }}
<img class="w-full rounded-lg single_hero_round nozoom" width="{{ .Width }}" height="{{ .Height }}" src="{{ .RelPermalink }}"> <img class="w-full rounded-lg single_hero_round nozoom" alt="{{ $alt }}" width="{{ .Width }}" height="{{ .Height }}" src="{{ .RelPermalink }}">
{{ end }} {{ end }}
{{ end }} {{ end }}
{{- end -}} {{- end -}}