Archived topic
alt tags broken?
6 replies · Started by Michael on April 25, 2022
Hi,
Trying to tidy up my site by adding alt tags to missing entries. When I looked at the console it's showing alt as empty, but not even with quotes as in alt="" ?

There's an alt tag defined for this image and many others, so not sure what is stopping them?
Hi there,
an empty alt tag is generally the result of WordPress adding the image when no Alt tag was available.
You can test for this by removing the image, publishing the changes, and re-adding the image with the Alt tag in place.
Make sure to clear any caches afterwards.
If thats the case then selecting an Image in the Media Library and opening the Image Details editor and updating the ALT tag there and hitting Update should also fix the issue.
You may need to clear any caches and if you're using a image optimizer it too may need to regenerate its work ( i cant say for sure here )
Hi David,
Thanks for the information, the first test you suggested worked, however the thought of selecting each image in the media library (over 4000 of them) and updating alt tag there seems a task and a half. I've been using a plugin which allowed me to edit alt tags without going into each image separately. It worked well, and all the alt tags I created are there. So now I guess I need a way to force an update somehow.
Looking into this further, seems that the gutenberg image block doesn't have it's alt information populated from the media alt tag, which is annoying. So all the images I had pre-gutenberg will need to be updated as well.
Appreciate the wisdom as always. :)
Yeah that is a pain, the alt tag is saved as static data in the content when the image is first inserted.
A database search and replace may be the only way to fix them in bulk.
There are some other approaches such as using filter hooks to amend the image, but that can get real complicated and messy.
Glad to be of some help
Hi,
Yes, that's how I've had to do it, at least in the short term. If I find a way to do it via database I'll use that. I've got a plugin that inserts a generated alt tag, not perfect, but it'll do for the time being.
Thanks again David
Just wanted to follow up this with a solution!
There's a plugin called Media Library Assistant which is an all purpose media helper, within that you can install a separate plugin called MLA Insert Fixit, which (amongst others) will read the alt tag from the media file, and insert it into the code of the post or posts in question so that the Gutenberg blocks now have the alt tag from the media file. Huge time saver for anyone stuck with this.
Awesome - thanks for sharing that