Infer whether an image's alt tag is missing or could be improved.
alt_check( attributes_df, max_char = 125, min_char = 20, file_ext = ".jpg$|.jpeg$|.png$|.svg$|.gif$", redundant_pattern = "image|picture|photo|graph|plot|diagram" )
attributes_df | A data.frame/tibble with image attributes, produced by
|
---|---|
max_char | A numeric value. Alt text longer than this is flagged. |
min_char | A numeric value. Alt text shorter than this is flagged. |
file_ext | A character string. A regular expression of image file extensions. |
redundant_pattern | A character string. A regular expression of 'redundant' phrases in alt text. |
A tibble object with classes tbl_df
, tbl
and
data.frame
. In addition to columns provided by
alt_get
, also returns:
alt_exists
"Exists", "Missing" or intentionally "Empty".
nchar_count
Integer. Number of characters.
nchar_assess
"Short", "Long" or "OK", depending on inputs
to min_char
and max_char
.
file_ext
Logical. Does it look like the alt text might
just be a filename (e.g. ends with ".jpg")?
self_evident
Logical. Is a redundant phrase used in the
alt text (e.g. "a picture of")?
terminal_punct
Logical. Does the alt text end with
terminal punctuation, like a period, to allow a screen reader to
parse it as a sentence?
spellcheck
Character. Words to check for misspelling.
These could be misread by a screenreader.
not_basic
Character list column. Words that match to
the 850 words of Charles Kay Ogden's Basic English.
if (FALSE) { url <- "https://alphagov.github.io/accessibility-tool-audit/test-cases.html#images" attr_df <- alt_get(url) alt_check(attr_df) }