Codeable info

How To Fix The Auto Thumbnail Problem In WordPress 3.4

Posted on by in WordPress Tutorials

When I announced the release of WordPress 3.4 last week I briefly mentioned a problem with auto thumbnail generating plugins. This turned out to be a big problem for me personally as I run four our five websites that use a plugin to automatically generate thumbnails.

The plugin I use is called Auto Featured Image. The plugin allows you to automatically generate the featured thumbnail for a post using an external image or from a video website such as YouTube, DailyMotion or Vimeo. It’s an incredibly easy plugin to use. You simply install the plugin and the plugin does the rest. It can also generate thumbnails for all posts that don’t have thumbnails currently.

Problems With WordPress 3.4

I’ve became quite lazy when updating WordPress. I no longer backup my files and database manually because VaultPress does it all for me and allows me to do a restore at the click of a button. So when WordPress 3.4 was released last week I uploaded the files to around 8 WordPress websites I run. I then found out that the featured thumbnails from 4 of my websites had been removed. They were simply not showing any more.

Rather than just restore the sites, I looked into how the problem could be resolved. Via the forums, I quickly found out that WordPress users who used Auto Post Thumbnail were experiencing. As you would expect from two plugins that perform similar tasks, they use a lot of the same functions. Due to this, the problem with WordPress 3.4 can be resolved in the same way for both plugins.

To fix it you need to edit the main plugin file. For Auto Featured Image this is auto-featured-image.php and for Auto Post Thumbnail this is auto-post-thumbnail.php. Then look for the following piece of code:

wp_update_attachment_metadata( $thumb_id, wp_generate_attachment_metadata( $thumb_id, $new_file ) );
return $thumb_id;

After the wp_update_attachment_metadata you need to add update_attached_file( $thumb_id, $new_file );. Therefore the code will now look like this:

wp_update_attachment_metadata( $thumb_id, wp_generate_attachment_metadata( $thumb_id, $new_file ) );
update_attached_file( $thumb_id, $new_file );
return $thumb_id;

Please bear in mind that this will only affect future posts so you will have to delete all unattached images on your site and then run the plugin again to regenerate the featured thumbnails.

Thanks to misthero for the above solution (and Paul OFlaherty for re-sharing it).

Not A Perfect Solution

The above solution works well though it’s not perfect. I used the fix on four websites and I was baffled by the different results I had. For one site the plugin worked perfectly. For another it worked well but a few posts did not have thumbnails. The other two websites had problems with it in which most draft posts and scheduled posts did not have a thumbnail. I’m still unsure as to why I had problems with two of the four websites as the websites are all set up in a similar way with the same plugins installed etc.

If you are looking to generate thumbnails from video websites, I recommend giving Video Thumbnails a try. It was designed to generate video thumbnails for a WordPress template however these thumbnails can also be set as featured. Like the other two plugins, you can also do a batch run to apply featured thumbnails to older posts.

I hope you found this useful. If you are unsure about anything please let me know and I’ll do my best to help :)


Codeable info

Comments (1)

Comment by Vikas Sindher says:

Thanks for this valuable information.I was facing the thumbnail problem.

Codeable info