Skip to content

alt text generated from filename can be harmful for screen reader users #30096

Description

@ckundo

👋 Hi Rails friends! Here's something that's been on my mind, hopefully helpful for improving Rails accessibility support:

Autogenerated alt text based on filename creates naïve descriptions that can do more harm than good. The content generated by automatically adding alt text can lead to a 300% increase in reading content, creating fatigue for screen reader users. If the content is not useful, this is a waste.

Autogenerated alt text also creates false negatives for linting tools that look for images that need descriptions.


If I'm adding a logo to a header in a document, I may use the image_tag helper.

<%= image_tag "logo.png" %>

That renders:

<img src="/images/logo.png" alt="Logo" />

The alt text "Logo" will be announced to screen reader users (blind, low vision, and sometime dyslexic folk). "Logo" is not a useful description and adds unnecessary content.

This whitepaper on alt text by TPG suggests that filenames as alt text are often useless.

The results clearly indicate that the amount of content conveyed to the screen reader user is increased by around 300% (comparing the length of the texts from the Fangs output) when no alt text is provided. How much of this is useful? From reading or listening to the output it is clear that the file names do not provide any clue to what is contained within the images

Expected behavior

Logos

In the logo.png example, the alt text should read the company name. There might be heuristics to automate that, but even in this simple case it's likely easier and more robust to rely on the author.

It is common practice on the web to have the main site logo also link to the site home page. Because this is fairly standard practice, providing alternative text for the image, such as your company name (alt="Acme Company), will usually suffice. Identifying the logo as actually being a logo (alt="Acme Company Logo") is not typically necessary. The content and function is not "logo".

http://webaim.org/techniques/alttext/#logos

image_tag ideally would not add automatically generated alt text. The behavior for screen reader users would not change much, since most screen reader tech falls back on filename with no alt text is present anyways. It may cause automated testing an linters to fail since no alt attribute is added. These failures would arguably be correct.

Next best solution would be an application level configuration options to set filename autogeneration.

config.action_view.alt_text_default = :filename

System configuration

Rails version:
Rails 5.1.3

Ruby version:
ruby 2.4.1

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions