dequelabs / dequelabs/axe-core

Warn alt attributes that are files / paths

Open
#3,685 3 comments 12 reactions 0 assignees View on GitHub
feat rules
Dominant language
JavaScript
Stars
7.5k
Forks
933
Avg merge
2d 13h
Merged PRs (30d)
29

Description

### Product

axe-core

### Feature Description

The latest [Web Almanac section on accessibility](https://almanac.httparchive.org/en/2022/accessibility#conclusion) has this nugget at the end:

> …we see that 2.2% of alt attributes across websites have a file extension in them…

From memory, I used to encounter these frequently enough in accessibility reviews that I knew Axe does not flag those for review. While 2.2% may be a small percentage, with 8,360,179 sites in the June 2022 data set, that suggests up to 183,924 sites could have this construct (all those bad alts could live on one site for all I can tell from the report).

Obviously there are cases where this may be valid, such as for downloads where the `alt` represents either text of the image, file links in general, or when the file name is incidental to other content in the `alt`.

I built a test: https://codepen.io/aardrian/pen/jOxYZXd

The code:
```


https://assets.codepen.io/2729/steamed-hams_08.jpg


steamed-hams_08.jpg


```

One of those is arguably a 1.1.1 issue and the other arguably a 1.4.5 issue. But a human would need to confirm that.

My suggestion is that Axe flags for review images with `alt` attributes that can be file names/paths. Whether looking at extensions, URL patterns, slashes, and so on, I defer to the multitude of regexes already out there.

Currently WAVE and ARC both flag those two constructs for review.

I do not know what editors / CMSes / tools still default to the file name as the `alt` value. [Hidde indicated](https://twitter.com/hdv/status/1574743520346509314) that Perch does. I know some WordPress plug-ins did (maybe still do), but I cannot recall which. Either way, it is not clear how much of that 2.2% is legacy content and how much is new.

Contributor guide

Open the contributing guide

Research direction

The issue names no repository files or tests. Start by reproducing the two CodePen examples and reviewing how existing axe-core image-alt checks handle review-only findings. Done means the detection scope for file names or paths and valid exceptions is agreed and covered by tests, but the issue does not specify implementation files or test locations.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
accessibility
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.