WebAIM - Web Accessibility In Mind

E-mail List Archives

Re: How to dynamically fix thousands of images missing alt attributes using regular expression find and replace

for

From: Steve Green
Date: Jun 14, 2019 1:04PM


That's not quite true - images in links can have alt="" as long as the link also contains text. I can see this regular expression getting quite complicated!

Steve

-----Original Message-----
From: WebAIM-Forum < <EMAIL REMOVED> > On Behalf Of Jared Smith
Sent: 14 June 2019 20:00
To: WebAIM Discussion List < <EMAIL REMOVED> >
Subject: Re: [WebAIM] How to dynamically fix thousands of images missing alt attributes using regular expression find and replace

> From what I recall though, the original person was asking how to update the alts for thousands of spacer images that are not informative, and it is impossible to do this manually one by one.

This makes more sense. This could be useful for fixing these. The concern is that if a web sites has thousands of spacer images without an alt attribute, they almost certainly have loads of images that should have alt text defined. These would get caught up in the mix and be given alt="".

One relatively simple improvement I would recommend is to detect if the image is inside a link. Such images should never have alt="", so it would be best to omit these.

Thanks,

Jared