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.

I have a Custom Post Type called species - fishkeeping species profiles.

Each species profile can have as many media attachments as it needs, plus a separate featured image.

I've dealt with this by storing it in the postmeta table under the key attached_media and it'll look something like this: a:3:{i:0;i:10081;i:1;i:10082;i:2;i:10083;}. This is an array of post_IDs of image files.

This website is a redevelopment of an existing one and to pull the information across - including images - I've written a script which communicates with both old and new databases.

This has worked, to an extent. The images are in place, but they're displaying at full size even when I've used the following code:

$size = "species-thumb";
wp_get_attachment_image( $attachment_id, $size, $icon, $attr );

The species-thumb size is set correctly as if you create a new species profile, any uploaded images are resized to the correct size.

If I create a new species profile, all of the image sizes are correct. Having done my database import however, only the full size images appear.

This is presumably because WordPress hasn't created the new image sizes (200*x for species-thumb) for these images.

I thought that I could simply run the AJAX Thumbnail Rebuild plugin, but it doesn't appear to work. The plugin works - it runs through all of the images (and displays each one on the screen), but then I can't find any images with names like filename-200x78.jpg.

Q: What's the best way to go about producing these images' thumbnails? It may be worth noting that there are over 4,000 images.

Thanks in advance,

share|improve this question
    
Just a thought - I never had much luck with that plugin either, but ViperBond's Regenerate Thumbnails works perfectly for me on a number of sites: viper007bond.com/wordpress-plugins/regenerate-thumbnails (and it manages several thousand images on my server, albeit somewhat slowly) –  Amanda Mar 9 '12 at 9:04
    
I think I tried that plugin yesterday, but I couldn't work out if it would do custom thumbnail sizes? It seemed to suggest it would only generate the thumbnail sizes from the Media Library settings. –  dunc Mar 9 '12 at 9:07
    
If you have custom sizes specified in your functions file, it will generate those, as well as the ones specified in the Media settings. My theme has about a dozen different image sizes, and it does all of them, plus the standard defaults. –  Amanda Mar 9 '12 at 9:09
    
Ooh, excellent, I'll give that a go. Thanks Amanda - feel free to post it as an answer so I can give you the credit if it works :) –  dunc Mar 9 '12 at 9:13
    
I'd try it on a handful of images first, rather than all 4000 straight away ;) Holding thumbs for you that it works - will be a simple, no-hassle solution for you if it does. But you might want to batch it into groups of, say, 500 photos if your server struggles. –  Amanda Mar 9 '12 at 9:38
add comment

1 Answer

up vote 2 down vote accepted

I never had much luck with that AJAX plugin either, but ViperBond's Regenerate Thumbnails works perfectly for me on a number of sites: viper007bond.com/wordpress-plugins/regenerate-thumbnails

It manages several thousand images on my server, albeit somewhat slowly, although you can also run it on individual images or batches of images from the Media library.

If you have custom sizes specified in your functions file, it will generate those, as well as the ones specified in the Media settings. My theme has about a dozen different image sizes, and it does all of them, plus the standard defaults, with no problems.

This plugin is one of my must-haves for one particular site, as they get a new design every year, and sometimes the old post thumbnail/featured image size doesn't work with the new design, so I have to run this reasonably often, on an ever increasing number of photos :)

Batch processing

For large media libraries it might be a little slow. It has successfully managed several thousand photos on an overnight run on one of my servers, but on others I find it times out sometimes. Then I just change the number of photos displayed in the Media Library to some reasonably sized batch, like 500, and "select all" on that page and run the regeneration page-by-page. That can be somewhat painful, but you can find a batch size that works for you if your server doesn't cope with the full library regen.

share|improve this answer
1  
This plugin made me work out the problem - when I'd done the database import, I hadn't set _wp_attachment_metadata or _wp_attached_file meta entries. It must be these that the AJAX Thumbnail Rebuild plugin works on BUT it doesn't give you any kind of error information. The plugin you've suggested gave me enough information to diagnose the problem. Thanks! –  dunc Mar 9 '12 at 10:29
1  
Glad to help - I've found answers here are frequently like that - might not be quite the right answer, but it gets you on the right track in the end :) –  Amanda Mar 9 '12 at 10:35
add comment

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.