An experimental R package to assess the alternative (alt) text from a web page.
Scrape image element attributes from a webpage, detect alternative (alt) text and assess it with simple heuristics. Alt text is important for users of assistive technologies, like screen readers, for understanding the content of images. This package should be used in conjunction with other accessibility assessment tools for more comprehensive coverage.
Read more about this package in the accompanying blog post.
Install from GitHub using the {remotes} package:
install.packages("remotes")
remotes::install_github("matt-dray/altcheckr")
library(altcheckr)
There are two major functions for now:
alt_get()
creates a tibble of HTML attributes for each 'img' element on a supplied web pagealt_check()
performs basic checks of the alt text for each image
See the 'introduction to {altcheckr} functions' vignette for more information: run vignette("introduction", altcheckr)
or visit the {altcheckr} website.
Right now, the alt_check()
function flags when alt text:
- is missing (but this is okay if the image is decorative)
- is noticeably short or long (length can be controlled by the user)
- contains self-evident phrases ('image of', 'picture of', etc)
- is missing terminal punctuation, which interferes with how the sentence is parsed
And it also:
- highlights words that may be misspelled, via the {hunspell} package
- returns a list of words that don't appear to be basic English
- Wikipedia's page for the alt attribute
- W3C's web accessibility tutorials on images, including a decision tree for using alt text
- Web Content Accessibility Guidelines (WCAG) overview
- Royal National Institute of Blind People's (RNIB) accessibility guidelines for alt text
Please note that the 'altcheckr' project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.