Update Attached Image Size after Import

I’ve just had this or a very similar problem (I didn’t use the WP export tool, but instead did a manual migration from one environment to another).

As far as I can tell, the problem occurs because of how WP stores the thumbnail data in the the wp_postmeta table (with the key ‘_wp_attachment_metadata’). This data is serialised, so it’s possible/likely that in your new import, the length of the individual meta values has changed, thus breaking the serialised data. So my theory is that this is why WP defaults to outputting the standard image – it can no longer parse the data.

I was able to fix this by running the regenerate thumbnails plugin (http://wordpress.org/plugins/regenerate-thumbnails/). Please note – for some reason this only worked the third or fourth time I tried it – very strange- I may have had a permissions problem that caused the thumbnail to silently fail at first. This regenerated the _wp_attachment_metadata field and after this, the correct images were output.

To clarify, I had the following situation (I think yours is the same but it’s good to be clear):

  • I had the relevant ‘add_image_size’ declarations in my functions file for all my custom sizes
  • the files themselves existed in the file system at exactly the same path
  • in my theme template, I was calling the images using the custom name – e.g.

    the_post_thumbnail('my-custom-name');
    

Hope this helps.