Generate Post Thumbnails

UPDATE: Now supports externally hosted images.

UPDATE2: Externally hosted images generation was improved.

WordPress 2.9 introduced the new feature Post Thumbnails. This feature allows to assign post thumbnail at post Edit page for each post, specify post thumbnails sizes in theme settings, and easily call post thumbnail of specified size in any place of the theme. Read more information about this feature at Mark on WordPress – New in WordPress 2.9: Post Thumbnail Images

The plugin Generate Post Thumbnails helps to automatically create post thumbnails for existing posts using post images. This plugin by default takes the first image in the post content and assigns it as a post thumbnail according to specified settings in the theme.

Plugin management page

I found this helpful after I decided to use Post Thubmnails feature in existing WordPress blog. I upgraded my WordPress to 2.9 and altered my theme settings according to New in WordPress 2.9: Post Thumbnail Images. I had hundreds of posts already, so I needed an automated script to run through them and assign my first post image as a post thumbnail. This is when this plugin came in handy. It is working using Ajax requests, so there is no timeouts issues. For my 200 posts it has been executing for 4 minutes. Anyway, this is faster than to do this process manually.



  • Download plugin
  • Extract zip in the /wp-content/plugins/ directory.
  • Activate the plugin through the ‘Plugins’ menu in WordPress.
  • Open the plugin management page, which is located under Tools -> Generate Thumbnails. If you get plugin warning, that means either your theme does not support WordPress Post Thumbnails feature or your WordPress version is lower than 2.9. See related links for more information.
  • Set Overwrite parameter, if you want existing post thumbnails to be overwritten by generated thumbnails.
  • Set the number of the post image, that you want to be used as your post thumbnail.
  • Click on Generate Thumbnails and wait until process is finished.
  • After this plugin assign all post thumbnails I suggest to use Regenerate Thumbnails plugin if you changed your media settings or theme post thumbnails settings and need to regenerate new thumbnails.

More useful plugins:

  • Regenerate Thumbnails – recreates already existing post thumbnails after changing their settings; however, it does not assign them if the post has no thumbnails yet.
  • Auto Post Thumbnail – generates post thumbnail after post saving.
    • Orphee

      Hello ! That script is very useful, but how can I automatically remove the first image from the post ? coz now, my thumbnails are well generated but the picture still in the post so it’s display twice (in a post view) , I’d like to delete the image from the post .
      Any idea ?

      Thanks in advance

    • Maria

      Orphee, probably your theme display featured image. You can remove featured image tag from your theme template.

    • Orphee

      Hi Maria, thanks for your answer. But my theme displays everything great, the only feature I’m looking for is in order to remove the image from the post, once it’s been auto generated as thumbnail, then I will not have thum + image in my post but only thumb.
      I hope I’ve been more understandable 😉

    • Maria

      Orphee, I guess, then you need to edit your posts to remove image from there.

    • Orphee

      That is what I was affraid of 🙁
      I will find an other solutions (too many posts to edit ^^ )
      thanks for your time

    • Maria

      Yeah, probably you need a script to parse your blog posts content and remove first image.

    • Lorina Daiana

      Mine keeps staying at 0%, I’m guessing it’s cuz I have so many posts up.. I was trying to do this so that the Related Post Thumbnails plugin would work. It use to work but for some reason it doesn’t show the images anymore.. unless it has a featured image on the post.. any idea what I can do? I honestly can’t find another plugin that I like better and would really like this to work

    • Trek Stuff

      Hi, I ran the plugin, but it didn’t do exactly what I needed, how do I remove generated plugins from the posts? Thanks!

    • Andrew Bolkonskii

      gluten free diet

    • Claudio

      Hello Maria,
      The images in the same folder when uploading
      This can cause future problems with the number images in the same folder.
      It is possible to resolve this problem as follows:

      Line 176 -> $wud = wp_upload_dir(get_the_time(‘Y-m-d H:i:s’, $post_id));

      Line 210 -> if ( ! ( ( $uploads = wp_upload_dir(get_the_time(‘Y-m-d H:i:s’, $post_id)) ) && false === $uploads[‘error’] ) )

      Line 74 -> if ( ! ( ( $uploads = wp_upload_dir(get_the_time(‘Y-m-d H:i:s’, $post_id)) ) && false === $uploads[‘error’] ) ) :

      Thus the images go into folders with the dates of posts…

    • Jorgelcar

      Thank you for your plugin. It is wonderful, easy to use, also for a dummy like me. I think that it could be fantastic if your plugin has a “carousel” caracteristic. Thank you again. Best ragards.

    • Vitaly

      Post: 139. Remote server does not return image…

      I have this issue, any solutions?

    • Robin

      Maria, is it possible to make this work with the simple-post-thumbnails plugin.
      I used that plugin in my blog for 4 year and now i want to move all the images to feature images. I hope you can help me.

    • Ryan

      awesome plugin. Saved me a TON of time. Thank You

    • noé

      hello Maria,
      does it works with external hosted images like picasa?

    • Guest


    • glorb


      Thanks for this plugin! I’ve used it on the latest wordpress version 4.2 and it works perfectly.

      I tweaked the code a little bit for my requirements and added a
      shuffle($posts_ids); at start because my server tends to time out on big requests.

      The other thing I changed is the ability to take gallery images as a thumbnail if the post only uses gallery images. I think it’s an interesting feature. Sadly I used it for my purpose so the code can’t be used as such anywhere :

      //line 183

      if ( isset($matches) && isset($matches[1][$imagenumber-1]) && strlen(trim($matches[1][$imagenumber-1])) > 0 )

      $image = $matches[1][$imagenumber-1];

      else if(has_shortcode( $post->post_content, ‘gallery’ ) ){

      $imgs = array();
      $gallery = get_post_gallery_images( $post );

      // Loop through each image in each gallery
      foreach( $gallery as $image ) {
      $imgs[] = str_replace(‘-400×400’,”,$image); //this need adjustments

      $imgs = array_unique($imgs);

      $image = $imgs[$imagenumber-1];


      else { // if image was not found in post

      return 6;


    • Progrmer

      Got any solution?