Targeting only post thumbnails for rebuild
-
Hey, awesome plugin. great job. very useful!
I had to run this on a site with a massive, massive, amount of images after a change to the template and re-structuring of post thumbnail sizes. We didn’t need to hit every single image for a rebuild so i modified your plugin to only hit images marked as a post thumbnail.
I think that this would be a great option to include, so i’m including the code i used. i’m sure there’s probably a better way to code that up, but this worked for me. i just swapped this code in around line 158 and replaced the existing $attachments.
//query only featured image id's $featured_images = $wpdb->get_results( "SELECT meta_value FROM {$wpdb->postmeta} WHERE meta_key = '_thumbnail_id'" ); //convert the featured_images array down into one dimensional array of id's $thumbs = array(); foreach($featured_images as $image) { array_push($thumbs, $image->meta_value); } //re-recreate attachemtns to get_posts $attachments =& get_posts( array( 'post_type' => 'attachment', 'post_mime_type' => 'image', 'post_status' => null, 'numberposts' => 200, 'offset'=> 0, 'orderby' => 'post_date', 'order' => 'DESC', 'post__in' => $thumbs, // any parent 'output' => 'object' ) );
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Targeting only post thumbnails for rebuild’ is closed to new replies.