1

I'm looking for a way to regenerate all images in media library and set ALT and TITLE to those that missing.

Something like what this plugin do + what I mentioned.

All codes people prepared are for set it WHILE UPLOADING image, not for images are already in media library, like this one:
https://brutalbusiness.com/automatically-set-the-wordpress-image-title-alt-text-other-meta/

changing titles/alt-text for previously uploaded images is a COMPLETELY different problem than what the code in this post aims to solve, because of the way WordPress handles images that are inserted into posts/pages.

The key point regarding previously uploaded images is that when you insert those images into a post/page, the image title and alt-text are COPIED into the html of the post/page by WordPress. So if you subsequently change the title/alt-text of the image in the media library, it will NOT affect any post/pages where that image is displayed, since the title/alt-text of the image was copied over into the post/page (and therefore will NOT be refreshed with the new image/alt-text from the media library).

Any updated image title/alt-text in the media library will only appear on posts/pages when the image is inserted into the post/page AFTER the title/alt-text was updated in the media library.

any idea will help.

1

Full disclaimer, I am the author of the WordPress plugin I am about to mention and I am hoping this answer would give it more visibility.

So, I had to do this for a few clients last year mostly for SEO reasons and it was getting ridiculous. I made a WordPress plugin that can do just what you asked. Bulk update all WordPress image attributes in one go. You can find it here: https://imageattributespro.com

What it does is, it goes image my image, finds all the posts where the image is inserted into and then updates the alt text and image title right within the post.

Uses WordPress functions to do all these, so never had any issue like a corrupt database or anything. But obviously its a good practice to backup your db before you update anything in bulk.

There is option to update only what isn't already updated, so for all the images that you have custom stuff already in place, they won't be affected at all.

You can see a video of this in action:

https://youtu.be/Z0zVaqqE7iE

Hope that helps. If you have questions, do let me know :)

0

To fill all alt meta with title you can use following MySQL script in phpMyAdmin:

INSERT INTO wp_postmeta (meta_id, post_id, meta_key, meta_value) 
SELECT '', p.ID, '_wp_attachment_image_alt', p.post_title FROM wp_posts p 
WHERE p.post_type = 'attachment'

You should remove all _wp_attachment_image_alt entries first to prevent duplicates.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.