Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Only wrap images with alt text in hyperlinks
When we wrap images in hyperlinks, we make the image's alt text their only content. If those images have no alt text, they are effectively empty links. This means they have no accessible name if queried by an accessibility API: https://w3c.github.io/html-aam/#img-element-accessible-name-computation ...so it'll be up to the screen reader to guess. In testing, this ends up being the file name, which can't be relied on to explain the image. All in all, this behaviour breaks the non-text content success criterion from WCAG 2.2: https://www.w3.org/WAI/WCAG22/Understanding/non-text-content.html This issue is recorded here: #355 This commit take the approach of introducing a guard against images with no alt text and choosing not to wrap them in hyperlinks when found. My Ruby is basic at best but I looked at the method we're overwriting from the Red Carpet HTML renderer and copied across its interface more exactly, to make it clear where the alt_text variable comes from.
- Loading branch information