最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

plugins - Regenerate images with automatic ALT and TITLE attributes

programmeradmin0浏览0评论

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:
/

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.

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/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.

Share Improve this question asked Feb 3, 2018 at 21:40 AminoAmino 3232 gold badges5 silver badges17 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 4

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

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 :)

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.

发布评论

评论列表(0)

  1. 暂无评论