Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

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'"

share|improve this question

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.