Add accessilbilty check and fixes
This commit is contained in:
parent
6c626450e7
commit
18d9cc15e7
16 changed files with 206 additions and 29 deletions
30
layouts/_markup/render-image.html
Normal file
30
layouts/_markup/render-image.html
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
{{- /*
|
||||
Content images. The Markdown title ("") is the photo credit; it is shown
|
||||
as a caption instead of a tooltip, so that it is available on touch devices and to screen readers.
|
||||
An image on its own line becomes a figure; images sharing a paragraph get an inline credit.
|
||||
*/ -}}
|
||||
{{- $src := .Destination -}}
|
||||
{{- $width := 0 -}}
|
||||
{{- $height := 0 -}}
|
||||
{{- with or (.PageInner.Resources.Get (strings.TrimPrefix "./" .Destination)) (resources.Get .Destination) -}}
|
||||
{{- $src = .RelPermalink -}}
|
||||
{{- if and (eq .ResourceType "image") (ne .MediaType.SubType "svg") -}}
|
||||
{{- $width = .Width -}}
|
||||
{{- $height = .Height -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- /* A title that only repeats the alt text is not a credit. */ -}}
|
||||
{{- $credit := cond (eq .Title .PlainText) "" .Title -}}
|
||||
{{- $img := printf `<img src="%s" alt="%s"%s>` (htmlEscape $src) (htmlEscape .PlainText) (cond (gt $width 0) (printf ` width="%d" height="%d"` $width $height) "") -}}
|
||||
{{- if .IsBlock -}}
|
||||
<figure class="content-image">
|
||||
{{ $img | safeHTML }}
|
||||
{{- with $credit }}
|
||||
<figcaption class="content-image__credit">{{ . }}</figcaption>
|
||||
{{- end }}
|
||||
</figure>
|
||||
{{- else if $credit -}}
|
||||
<span class="content-image">{{ $img | safeHTML }}<span class="content-image__credit">{{ $credit }}</span></span>
|
||||
{{- else -}}
|
||||
{{ $img | safeHTML }}
|
||||
{{- end -}}
|
||||
Loading…
Reference in a new issue