Skip to content

jsx_a11y/img-redundant-alt Correctness

What it does

Enforce img alt attribute does not contain the word image, picture, or photo. Screenreaders already announce img elements as an image. There is no need to use words such as image, photo, and/or picture.

Why is this necessary?

Alternative text is a critical component of accessibility for screen reader users, enabling them to understand the content and function of an element.

What it checks

This rule checks for alternative text on the following elements: <img> and the components which you define in options.components with the exception of components which is hidden from screen reader.

Example

Examples of incorrect code for this rule:

jsx
<img src="foo" alt="Photo of foo being weird." />
<img src="bar" alt="Image of me at a bar!" />
<img src="baz" alt="Picture of baz fixing a bug." />

Examples of correct code for this rule:

jsx
<img src="foo" alt="Foo eating a sandwich." />
<img src="bar" aria-hidden alt="Picture of me taking a photo of an image" /> // Will pass because it is hidden.
<img src="baz" alt={`Baz taking a ${photo}`} /> // This is valid since photo is a variable name.

References

Released under the MIT License.