Plugin Description:
Regenerate Thumbnails allows you to regenerate all thumbnail sizes for one or more images that have been uploaded to your Media Library.
This is useful for situations such as:
- A new thumbnail size has been added and you want past uploads to have a thumbnail in that size.
- You’ve changed the dimensions of an existing thumbnail size, for example via Settings ? Media.
- You’ve switched to a new WordPress theme that uses featured images of a different size.
Download:
- Download from WordPress.org (0 downloads)
Screenshots:
God! I can’t believe this, recently i made some changes to my site and i started re-uploading pictures and swearing wordpress just yesterday for not updating the thumbs after i changed the settings. I will download this now and at least the rest of the posts will be updated more easily. You saved me tons of work! My lucky day! Thanks so much!!!
Pingback: Brian.Carnell.Com » Blog Archive » WordPress Plugin to Regenerate Thumbnails
Glad you like it and sorry that your comment got caught in my spam queue.
Thank you for this great Plugin.
What I am desperatly searching for is a plugin that compresses the base image as well, because some of our blog writers don’t compress their images before uploading. Maybe this could be added to?
Just in case anyone is still looking for a plugin that compresses base images while uploading, try WP Smush.it:
http://wordpress.org/extend/plugins/wp-smushit/
It doesn’t resize images on upload, but it does optimize them for the Web automatically.
Jörn: that feature won’t be making it into this plugin as that’s not really the purpose of it (it’s just meant for thumbnails), although it wouldn’t be hard to write a plugin that compressed all images as there were uploaded.
Maybe I’m misunderstanding, but couldnt this be done straight in wordpress? In Settings>Media… edit the max width of the Large size (leave max height blank). Though it would be nice to know how to build max image width straight into a theme.
Hey
Great, that’s the plugin I was looking for! thanks 😉
Tried it this morning: works nice… but the process stops systematically after approx 40 to 80 pictures 🙁 (actually, after a couple of secs: each run stops a at different picture).
I guess a timeout might kill the stuff… culprit not identified yet (php max execution time is 30 seconds).
Any idea?
Cedric M on September 26th, 2008 at 12:31 AM wrote:
My plugin resets the max execution time (to 30 seconds) after each image to make sure it doesn’t time out.
Try finding this in the plugin though:
set_time_limit( 30 );
And changing it to this:
set_time_limit( 0 );
See if that helps any.
I should probably also make it skip existing thumbnails if they’re already the correct size.
Nope, doesn’t change anything.
Looks like the web server isn’t returning anything to the browser until some timeout happens, at approx 10-15 secs… (and then, it seems that the browser receives the beginning of the page in a single shot).
I tried to add a
$this->flush();
in the processing loop, no success.Hmm……
Update: turning off gzip compression did solve the issue of flush() not working. Process is still stopped after ~10 secs though.
Quick ‘n dirty patch to your plugin: avoids regenerating thumbnails already at the correct size.
As my provider seems to have some watchdog to kill long running php processes, it enables me to hit the “reload” button until everything is done.
Cheers
Cédric
@@ -88,6 +88,10 @@
// Output progress so far to browser
$this->flush();
+ // Get thumbnail max size
+ $thumbnail_size_w = intval(get_option(‘thumbnail_size_w’));
+ $thumbnail_size_h = intval(get_option(‘thumbnail_size_h’));
+
// Loop through each attachment
$count = 0;
echo ” <ol>\n”;
@@ -100,9 +104,14 @@
// This is a better solution than just doing set_time_limit( 0 ); in my opinion.
set_time_limit( 30 );
– wp_update_attachment_metadata( $attachment->ID, wp_generate_attachment_metadata( $attachment->ID, $fullsizepath ) );
–
– echo ‘ <li>’ . str_replace( $uploadpath, ”, $fullsizepath ) . ” processed.</code></li>\n”;
+ $size = image_downsize( $attachment->ID, ‘thumbnail’ );
+ if (($size[1] != $thumbnail_size_w) && ($size[2] != $thumbnail_size_h) && (($size[1] + 1) != $thumbnail_size_w) && (($size[2] + 1) != $thumbnail_size_h)) {
+ wp_update_attachment_metadata( $attachment->ID, wp_generate_attachment_metadata( $attachment->ID, $fullsizepath ) );
+
+ echo ‘ <li>’ . str_replace( $uploadpath, ”, $fullsizepath ) . ” processed.</code></li>\n”;
+ } else {
+ echo ‘ <li>’ . str_replace( $uploadpath, ”, $fullsizepath ) . ” already at the correct size.</code></li>\n”;
+ }
$count++;
}
Cedric M on September 28th, 2008 at 2:47 PM wrote:
Mmm, good thinking. Thanks! 🙂
Great! also needed this tool.
Thanx very much for your time and sharing your work.
I unfortunately have a failed result. message recieved is:
All done! Processed 0 attachments in 0.018 seconds.
which seems a bit off since there are about 30 attachments.
I thought it might be a hard coded path in your code, not the case.
I am using WP 2.6.2.
If you have any thoughts as to why this doesn’t seem to be working for me,
I’m all ears.
Saludos
Daiv on September 29th, 2008 at 4:15 PM wrote:
Looking at my plugin’s logic, the only way that could happen is if my plugin couldn’t find the fullsize version. I’ll add more debugging output to the plugin when I add Credic’s code. Swamped at the moment though with work, so it’ll probably be a bit (few days I imagine, but who knows).
I’ve just added a new test post using the WP 2.6.2 image upload.
And your resize plugin does work for those files.
It doesn’t seem to be aware of images uploaded with WP > 2.5
Which I believe was the active version when I uploaded the previous images.
Also, my images html had been entered with modifications, I wrapped the image in a custom div if that might be a factor.
My plugin only resizes actual attachments (which are stored in the database) rather than everything in the uploads folder. I believe this change was made in WordPress 2.5 (due to galleries, etc.), but I could be wrong. I’ll look into it.
Yes sir, you are correct.
WP 2.5 changed the way it relates images to posts.
Images are related as attachments.
A benefit is that image A can be in post L and M as attachment, which
if you want can be clicked to view in theme/attachment.php and commented
on independently from post L and M.
Now to find out how to update all WP pre-2.5 posts automatically.
Thanx again for sharing your work, and responding to my questions.
Any plans to make an option where you can select the post ID for this to occur on rather than having it check all attachments? I plan on giving this a shot soon for some new photos I’ve taken. I had the medium size set up for my old camera, and well, the new one when resized to medium made the images narrower than my template. I’m assuming that if I’ve hot hard-coded to any of the medium size images, I can just delete the old ones after running the plugin, correct?
Also another item I’m stuck on, I need a way to re-extract the exif data from images already uploaded. Do you think that would be very hard? I posted on the WP forums and got a response, but it seems over my head unfortunately.
Shane on October 1st, 2008 at 7:16 AM wrote:
No, not really. This plugin is kinda in stasis for now due to a new job of sorts.
I don’t get what you mean about the new vs. old camera though.
As for EXIF, I take it these were uploaded pre-2.5? If so, you’d need some type of attachment importer or something. Before 2.5, the uploader was merely an uploader with a thumbnailing script. The uploads weren’t stored in the database if I remember correctly and so they weren’t tied to any posts (i.e. they were just files in a folder).
In 2.5+, data about the images are stored in the database (EXIF, thumb size, etc. etc.). My plugin grabs all attachments outta the database and then remakes the thumbnails if the file exists in the folder. It’s not aware of any images uploaded before data about them was stored in the database.
Thanks for the reply!
What I mean about old/new camera is I set the max height and width based off of the dimensions of my old pictures, so when I used my new one, they actually make a wider shorter image, so now some of my portrait images are narrow due to hitting the maximum height that I had set up. I should have only set the width to something that pertained to my theme, and did something huge for the height.
For my EXIF data, the images were uploaded post 2.5. My server didn’t have the exif extension installed. So now I’m stuck either reuploading the images to reextract the data, or just live w/o showing it.
Thanks again for your reply!
Shane on October 1st, 2008 at 5:00 PM wrote:
Gotcha.
It probably wouldn’t be too complex. I’d imagine it’d be similar to how this plugin works but instead of calling the thumbnailing function it’d call the EXIF function.
Sweet man! I wish I had the skills to take it on. Maybe someone will try it sometime, or if you ever have any freetime and decide you’d like to make something up to do that, I’ll shoot you a contribution or donation for your time.
Shane on October 2nd, 2008 at 1:51 PM wrote:
I wish I did, but I’m in the process of trying to get a new job so between that and a couple existing small-time clients, I’m swamped.
Thank you! Thank you! Thank you! again for posting this, saved me endless work!
Pingback: 185vfx | Automatically display images in Wordpress themes
Was the patch to skip correctly sized thumbs included? I’m getting some thumbs saying they’re processed, but then a fatal error of memory being exceeded. If I try to run it again it says the same thumbs have been processed, not new ones. Any ideas?
kristarella on November 6th, 2008 at 6:18 AM wrote:
No, I’ve been busy. It currently just regenerates all images regardless.
kristarella on November 6th, 2008 at 6:18 AM wrote:
Sounds like you’re trying to resize an image with a very large resolution. Make sure your server has a normal sized memory limit rather than the retarded default of like 8MB (which is nothing).
kristarella on November 6th, 2008 at 6:18 AM wrote:
This is normal. See the first part of this comment.
Thanks for the prompt reply, I will check into some of that stuff.
Thank you a lot for the plugin.
I have a problem with WordPress 2.7 – it shows me a message “No attachments were found. Go upload some!”
It is strange to me.
Anyway I found the following solution:
instead of the line 72
$attachments = get_children( ‘post_type=attachment&post_mime_type=image’ );
I put
$attachments = get_children( array( ‘post_parent’ => $post_id, ‘post_type’ => ‘attachment’, ‘orderby’ => ‘menu_order ASC, ID’, ‘order’ => ‘DESC’) );
Now it works fine!
$post_id isn’t set, so that does nothing and the order doesn’t matter either. However removing the post_mime_type may have been the real solution there. Your server may have not been marking the MIME type or something.
This a fantastic plugin that exactly does what I needed! THANKS! One question: after I resized everything from 150×150 to 75×75 I noticed that all 150×150 thumbs were still in the directory of server. Would you know if there a smart and simple way to get rid of them without going through all the directories?
Michiel on November 26th, 2008 at 8:17 PM wrote:
A custom PHP script would probably be the way to go I guess.
Pingback: ?? WordPress ? Gallery ?? | Dreamcolor's Cote
Same problem as Alexey above using 2.7 – his fix worked.
Thanks for this plugin, a real time saver – it should be part of the WP core!
As of version 1.1.0, everything should be working fine (I updated it for WP 2.7 and fixed that “bug” at the same time).
Not even sure if you can answer Viper, but would you have any idea why all images uploaded since Jan 2008 have ‘lost’ their thumbnail info.
I did an export from 2.7 RC1 before upgrading to 2.7, and in the process my images got all messed up. I can’t even view the images by entering in the URL to the file?
Images w/thumbnails (all pre-2008) can be viewed?
Tried your plugin and it claims to have processed all images, but no dice.
willyjsimmons on December 16th, 2008 at 10:56 AM wrote:
Export? As in the XML file? That isn’t a database export, it is a content exporter. It will not save everything in your database such as settings and such.
Viper007Bond on December 16th, 2008 at 5:15 PM wrote:
Export? As in the XML file? That isn’t a database export, it is a content exporter. It will not save everything in your database such as settings and such.[/quote]
Yes, the XML export. Also did a database backup, but I’ve had issues in the past rebuilding the site using just that for some reason. (database keys got screwed up)
That last time I went through this process, I used the XML file and didn’t have any issues with the thumbnails disappearing. And like I said, all the pre-2008 stuff is in tact?
Thanks a lot for this plugin! We wanted to change the thumbnail size for our site recently, this was a lifesaver.
Fantastic plugin! I’ve been searching for this functionality for a couple months now. Thanks so much for saving me hours of manual work.
Cedric M on September 28th, 2008 at 2:47 PM wrote:
Please can you upload a copy of the plugin patched?! Thanks!
I can’t get the patch to work either. Any chance you could update the plugin w/ the patch on this page?
Many Thanks!
Question if this will work for me: all of my thumbnail files are still in the upload directories, but my database had a minor corruption issue (postmeta table was corrupt and I restored from a backup but am missing data for past four months). Will your plugin write the thumbnail info into my database so WP will once again recognize that the thumbnails are there?
having wp 2.7 i have this problem trying to “Regenerate all Thumbnails”: Fatal error: Allowed memory size of 62914560 bytes exhausted (tried to allocate 85 bytes) in xxxxxx/wp-includes/functions.php on line 2901
Why this error ?
http://reynald.incident.net/archives/12/
Pingback: ????? | ?? WordPress ? Gallery ??
Steve on January 27th, 2009 at 11:50 PM wrote:
No. It does not look in your uploads folder for files. It uses the database to get a list of attachments.
Sorry.
ernesto on January 30th, 2009 at 6:36 PM wrote:
Unrelated to WordPress version. It’s trying to resize a huge image and running out of memory to do it with. Resize the original image manually to be a bit smaller in dimensions or increase your server’s PHP memory limit.
Reyd on January 31st, 2009 at 1:12 AM wrote:
I don’t understand what you mean. Sorry.
Is it possible to set thumbnail’s suffix (for example “Mini”), instead default size-base “_110x110”.
Thanks.
Amaxik on February 17th, 2009 at 10:56 AM wrote:
Possibly, but that’s not my plugin adding that suffix, it’s WordPress (as I use it’s thumbnailing API). Changing the suffix would be the job of a separate plugin.
Hello thank you for your plug-in is really a time saving. By the way i have a problem, i have many many posts with images and the plug-in only process them partially I don’t understand way? can u help me?
ciao leonardo