Skip to content

Automatically adds alt and captions tags to images in existing content when you add them in the media library

Notifications You must be signed in to change notification settings

DasBen/CasualBen-Automatic-Alt-And-Caption-Text

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 

Repository files navigation

CasualBen Automatic Alt and Caption Text

Automatically adds alt and caption text to images in Gutenberg block editor when you add the alt or caption text in the Media Library. This is an Extension of BE-Automatic-Alt-Text. I've added the functionality to auto update the caption too.

Original Description

When you insert an image into a post, the HTML is “hardcoded” into the post content. You can edit the image’s alt text in the Media Library, but this will only include the alt text for future uses of the image. It won’t automatically update all of the past uses of that image in your older posts.

The code below fixes this. When a page loads, it finds all of the images that are missing alt text and looks to see if you’ve specified an alt text for it in the Media Library. If so, it updates the image before loading the page.

You can now go to your Media Library and update the alt text for every image. You won’t have to edit every post and update each instance of the image.

Note: this will only work for posts that are using the Gutenberg block editor. Even if you’re using the block editor now, it’s likely that most of your older content is still using the classic editor.

You can use Bulk Block Converter to convert all the posts using the Classic editor to the Block editor, but be careful. I’d run the tool first on a staging environment and go through your posts to make sure there were no issues with the conversion.

About

Automatically adds alt and captions tags to images in existing content when you add them in the media library

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%