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: main:
weight: 3 weight: 3
identifier: Erwitt identifier: Erwitt
title: Erwitt
unifiedAlt: '© Elliott Erwitt'
--- ---

View File

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

View File

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

View File

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

View File

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