I have a blog with a lot (over 1000) images. Each image has a meaningful descriptive filename. WordPress has title caption and description fields for images. What’s the easiest way to batch process all images and copy the file name to the title alt description and caption fields. Also if I could update yoast seo fields too that would be great.
3 comments
Comments are closed.
You can make a query to loop through all the attachments, and then update the attachment info for each attachment in the while loop.
Something like
Did a quick search on how to get the attachment filename but couldn’t find it but this should get you started. Within the loop you should also be able to update the description. You can look at wp_update_attachment_metadata and als check this post (related to the filename).
I ended up writing a php file to quickly solve the problem.
Well, I was using lightbox gallery, and I needed to have the post title for my images as the alt text.
What I did was create a query on the database to update the post_excerpt to match the post title.
This seem to work for me and the lightbox gallery.