I uploaded around 600 pictures in different galleries in wordpress without setting the titles and alt attributes. I need to edit them, I was wondering a way to edit them by album, let's say the title of the pictures in the album soccer would be soccer1, soccer2 etc.. but without doing it manually?
2 Answers
You can use the 'wp_get_attachment_image_attributes' hook
add_filter(
'wp_get_attachment_image_attributes',
'image_attributes',
20,
2
);
function image_attributes( $attr, $attachment )
{
// Get post parent
$parent = get_post_field( 'post_parent', $attachment );
// Get post title
$title = get_post_field( 'post_title', $parent );
if ( is_single( $parent ) ) {
$attr['alt']=$title;
}
return $attr;
}
Or use this plugin
Alt Manager WordPress plugin bulk changes WordPress images Alt and Title attributes text and generate empty values on your (Homepage – Pages – Posts – Blog )[Free Version] (Products – Shop page – Custom Post Type – Custom Post Type archive page)[Premium Version] separately to several dynamic related values, This plugin is a full solution for generating alt and title values.
This Plugin bulk changes images Alt and Title attributes immediately on your website front end, you don’t need to change image info on media library. https://wordpress.org/plugins/alt-manager/
I think the better way to use this plugin - http://wordpress.org/plugins/faster-image-insert/ We have a photo website and we use this plugin for a bulk uploading and bulk editing image attributes. You can run action that will change all your titles in way soccer1, soccer2. You also can change the order of your images and rewrite titles again.