4

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?

1
  • forrst.com/posts/… this function seems to be kind of what you want though for all images with missing alt tags rather a category by category basis, but perhaps a start or compromise... – David Sep 20 '12 at 16:06
2

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 Check Out my new plugin

Its now on WordPress plugins directory. The Alt Manager plugin is a simple plugin that changes images Alt and Title attributes text on your (Pages – Posts) separately to your website name or (post or page) title.This Plugin bulk changes images Alt and Title attributes immediately you dont need to change image info on media library. https://wordpress.org/plugins/alt-manager/

0
-1

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.

1

Your Answer

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