Update Attached Image Size after Import

So I just exported all the data from one version of site, and imported it into a new version of that site (using the WP Import / Export options). I selected the box to download all attachments as well.

It downloaded them, and even made the appropriate custom image sizes that exist in the new site, however for every single post, it default to attaching the full size of the image, rather than the image sizes I have designated for Posts.

Read More

My question is, without going through each post one by one and assigning the correct image size, is there a way I can set all Post images to be a certain size? i.e. “Set all posts to the custom image size ‘blog-image’”

Related posts

1 comment

  1. 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.

Comments are closed.