chore(imageJSON.html): add alt attribute to images in imageJSON partial to improve accessibility

This commit is contained in:
Sped0n
2023-11-03 09:49:40 +08:00
parent 75dc3c9269
commit ed40ddd27e
5 changed files with 26 additions and 11 deletions

View File

@@ -6,4 +6,6 @@ menu:
main:
weight: 3
identifier: Erwitt
title: Erwitt
unifiedAlt: '© Elliott Erwitt'
---

View File

@@ -6,4 +6,6 @@ menu:
main:
weight: 1
identifier: Gruyaert
title: Gruyaert
unifiedAlt: '© Harry Gruyaert'
---

View File

@@ -1,11 +1,13 @@
---
type: _default
layout: single
url: /info/
url: /Info/
menu:
main:
weight: 4
identifier: Info
title: Info
unifiedAlt: ''
---
Bridget is a _minimal_ Hugo theme designed for photographers / visual artists.

View File

@@ -6,4 +6,6 @@ menu:
main:
weight: 2
identifier: Webb
title: Webb
unifiedAlt: '© Alex Webb'
---

View File

@@ -1,15 +1,22 @@
{{- $Page := .Page -}}
{{- $params := .Page.Params | merge .Site.Params.Page -}}
{{ $gallery := site.GetPage .Path }}
{{ with $gallery.Resources.ByType "image" }}
{{ $index := len . }}
{{ $Page.Scratch.Add "img" slice }}
{{ range . }}
{{ $index = sub $index 1 }}
{{ $lores := .Resize "800x webp Lanczos q60" }}
{{ $hires := .Resize "2500x webp Lanczos q75" }}
{{ $Page.Scratch.Add "img" (dict
{{- $gallery := site.GetPage .Path -}}
{{- with $gallery.Resources.ByType "image" -}}
{{- $index := len . -}}
{{- $Page.Scratch.Add "img" slice -}}
{{- range sort . "Name" "desc" -}}
{{- $image := . -}}
{{- $index = sub $index 1 -}}
{{- $alt := .Name -}}
{{- with $params.unifiedAlt -}}
{{- $alt = . -}}
{{- end -}}
{{- $lores := .Resize "800x webp Lanczos q60" -}}
{{- $hires := .Resize "2500x webp Lanczos q75" -}}
{{- $Page.Scratch.Add "img" (dict
"index" (int $index)
"alt" (string $alt)
"loUrl" (string $lores.RelPermalink)
"loImgH" (int $lores.Height)
"loImgW" (int $lores.Width)
@@ -17,7 +24,7 @@
"hiImgH" (int $hires.Height)
"hiImgW" (int $hires.Width)
)
}}
-}}
{{- end -}}
<script id="imagesSource" type="application/json">{{ $Page.Scratch.Get "img" | jsonify | safeJS }}</script>
{{- end -}}