WordPress.org

Ready to get started?Download WordPress

Forums

Regenerate Thumbnails
Call for specific attachment ID? (2 posts)

  1. joshkadis
    Member
    Posted 2 years ago #

    Is there a public PHP function that I call to regenerate the thumbnails for a specific image by passing the attachment's ID?

    http://wordpress.org/extend/plugins/regenerate-thumbnails/

  2. Alex Mills (Viper007Bond)
    Moderator
    Plugin Author

    Posted 2 years ago #

    Yes, look at how the ajax_process_image() function in my plugin works.

    Basically it's this though, although you should check for errors along the way (see function):

    // Get path
    $fullsizepath = get_attached_file( $image_ID );
    
    // Generate meta data (this makes the thumbnail images)
    $metadata = wp_generate_attachment_metadata( $image_ID, $fullsizepath );
    
    // Save the meta data so WP knows the thumbs exist
    wp_update_attachment_metadata( $image_ID, $metadata );

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic