Regenerate Thumbnails

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:

Screenshots:

823 thoughts on “Regenerate Thumbnails

  1. thanks for this plugin, I really need it. However it is not showing up in the bulk actions list on the media page. I have the latest wordpress v. 3.0.5 The plugin is very straight forward, I can’t see that I have done anything wrong. It does work on one thumbnail at a time which is a million percent on nothing. so thanks again.

  2. I’m having trouble with the plugin, it doesn’t seem to do anything – just shows the text below and sits there. What’s the first step in debug ? Are there any pre-req’s to the plugin working ?
    Dennis

    ========
    Regenerate Thumbnails

    Please be patient while the thumbnails are regenerated. This can take a while if your server is slow (inexpensive hosting) or if you have many images. Do not navigate away from this page until this script is done or the thumbnails will not be resized. You will be notified via this page when the regenerating is completed.

    (abort resizing images)

    Debugging Information

    Total Images: 1
    Images Resized: 0
    Resize Failures: 0

    • re above … sorry, problem is something to do with new wp3.1 Just rolled back to old version, and it works perfectly. It’s a great plugin, thanks.

  3. Thanks a lot for this plugin as it works well with the AutoFocus Theme. However, I have to say that it used to work fine. Someday and I unfortunately don’t know why it stopped working with photos in the portrait format or after I changed the contrast in Photoshop.
    Then, I always get the following messages:

    [b]Fatal error: Out of memory (allocated 31981568) (tried to allocate 3200 bytes) in /homepages/26/d27070005/htdocs/blog3/wp-includes/media.php on line 253[/b]
    Example for this on my blog: http://www.kunstgalerie-barbara.de/blog3/2011/02/28/what-the-future-holds/

    [b]Warning: imagecreatefromstring() [function.imagecreatefromstring]: Passed data is not in ‘JPEG’ format in /homepages/26/d27070005/htdocs/blog3/wp-includes/media.php on line 253[/b]
    After this error happened, the image won’t have the appropriate measurements on my front page but in the blog entry page it will be alright: http://www.kunstgalerie-barbara.de/blog3 –> blog entry from yesterday (26.2.)

    My hoster is 1&1 and I already read in another comment here that there can be problems due to this hoster but I am not very familiar with PHP issues. What do you think these problems originate from and how can I solve them?

    Thanks a lot in advance!

  4. 1&1 states on their site that the memory limit for all shared hosting accounts is set to 30MB and can’t be changed.

    1&1 doesn’t seem to allow people to circumvent this via the usual methods (wp-config.php, .htaccess or php.ini). I tried it just yesterday, even called 1&1 customer service. The service agent was trying to be helpful and suggested two of the methods above, but it didn’t work – and I found some blog posts confirming that 1&1 seems to block these attempts.

    So it looks like it’s a dead end, unfortunately.

    • 30MB is really not that much. WordPress attempts to set the amount of memory available to 32MB and it’s possible to go over that if you use a lot of plugins.

      Sounds like it’s time for a better host. Yours is cramming too many sites on each server.

  5. Thanks for your Plugin. I slightly altered your code and used it to rename images on the filesystem. I noticed that google not only digs ALT tags, but also filenames. Easy to find out while the site is in German and all resources have English names…

    One remark though: why is the Bulk Action not available at the Media Library?

  6. I don’t get how this is working for everyone. On WordPress 3.0.x it was working fine. Everyone that I talk to using it for 3.1 says it doesn’t work anymore. Isn’t it worth looking into? Also, how ’bout coming up with something that only uses a certain amount of memory? I’m no troll, I’m just saying

    • I’m using 3.1 on all my sites, and everywhere I have this plugin installed, it’s working fine for me (apart from the bulk regen option missing from the Media Library menu). Maybe you’ve got a conflict somehow with another plugin?

  7. Pingback: test 6

  8. Thanks so much for this plugin. Just wanted to give you heads up that the bulk regen is not working on my installation of 3.1 either.

  9. Pingback: Autofocus istructions

  10. I love this plug in but i have one problem – After running it on all my images the “Featured image” on each post is cut off at the top and bottom. Any way to rectify this? Thanks Again

  11. Ok. I am a photographer. Not a blog guy but I’m learning and trying. Would you mind explaining what that means? Do I disable cropping in the theme editor? I found the functions.php folder but don’t know what to do.

  12. To those inquiring about permissions for editors / and for Alex:

    The plugin currently works only for admins – more to the point, users with capabilities “manage_options”.

    On a private blog, maintained and updated by a single person, that perhaps makes sense. But on all WordPress websites that I work on, there is a distinction between the admins and the editors (and at times the authors). And WordPress is indeed built that way.

    Alex: In my opinion, the correct user capabilities should be ‘upload_files’ rather than ‘manage_options’. At the very least, this should be allowed for the single-image function.

    I, in the mean time, simply edited the regenerate_thumbnails.php file in the plugins dir, and replaced all ‘manage_options’ with ‘upload_files’. That way, editors on the sites I admin, can use this function in the Media library.

    Cheers,

    Biranit

    • My reasoning was that only someone with manage_options capabilities could change the settings of what size the thumbnails are or edit the theme’s featured image configuration. Everyone else had no need to run the script, especially since it can cause high server load.

      • Hi Alex,

        Thank you for your reply. I understand completely your reasoning.

        The thing is, your wonderful plugin is actually more useful than you initially imagined 🙂 On several of our wide-staff driven websites, this is a tool used all the time by our editors and photo editors – though not in bulk, and not due to the addition of another image size.

        The reason is that we receive and upload dozens of photos a day from various sources, and very often (several times a day in fact) we use the WordPress media editor to crop/flip/etc the images. After doing that, the editor then runs “regenerate thumbnails” on that specific image – and voila, all is good in our world 🙂

        Ideally, if you ever went that far, I would separate permissions:

        – only admins for the “tools->regenerate thumbnails” action (which affects ALL the images and indeed should be handled by an admin only)

        – editors for the single image / bulk “media” actions.

        Or, of course, you could create a settings page for the plugin that allows the admin to determine who should have permissions 🙂

        Anyway… for me personally it’s no big deal. I just have to remember to edit your php file every time we upgrade… 🙂

        Allow me to take the opportunity to thank you for this plugin, though. It is extremely useful!

        Cheers,

        Biranit

  13. Since last week this plugin don’t work anymore on my blog 🙁

    Yesterday i have started the plugin, i change all picutres to the selected size, but it don’t show it right on the blog-site.

    do you have any idea what this is?

    thank you

  14. I’m noticing that after a recent WP update, this plugin no longer shows up under ‘Settings’ for me to resize thumbnails.

    Any idea if there’s a compatibility issue or an easy way to fix it?

    Thanks,
    :Steve

  15. Hi,

    Love this plugin, used it a few times when I’ve changed my theme. One problem I’ve noticed this time though, have you any idea why it won’t regenerate thumbnails for png format images? It says it worked, but there are no images of the correct size, only the ones created by WordPress when they were originally uploaded.

    • If you upload a PNG image and thumbnails aren’t made then, then it’s not my plugin at fault. 😉

      It sounds like your server lacks the capability to manipulate PNG images for whatever reason.

  16. Indeed. As I said all thumbnails (even for PNGs) are created when uploading image via the WP uploader. The only time they aren’t created is when I run Regenerate Thumbnails.

    I realize your plugin actually forces WP to run it’s internal function to regenerate the thumbnails, but I was hoping you might have some idea as to why, even though WP can create the thumbnail during an upload, it can’t when your plugin tells it to.

    I’m mystified by why it would happen.

    • As am I.

      I just uploaded a PNG to my WordPress 3.2 beta 1 test site and the thumbnails were correctly made. I deleted the thumbnail files and ran my script and the thumbnail images were successfully recreated.

      • I’m currently running 3.1.2. I’ve just tried it again & noticed something strange. It is running and recreating the thumbnails for PNG files but it is only remaking the normal thumbnail sizes not custom ones. I noticed because the modified date of the thumbnails update every time I run the regenerate thumbnails.

        Have you any clues as to why WP doesn’t seem to be creating custom thumbnail sizes for PNGs but it does them fine for JPGs? Thanks in advance for anything you can think of.

        • I can’t reproduce that issue either. In my test, the custom Twenty Eleven thumbnail sizes were created during my PNG test.

          Sounds to me like it’s a bug with your theme or something in how it registers it’s thumbnail sizes or something.

          • The theme registers it’s thumbnails sizes just by using

            add_image_size();

            I’ll drop a question into the WP forum to see if they’ve any idea what could be going on. Thanks for the help.

  17. Pingback: New Property Sales Site | AppThemes Forum

    • My plugin uses the core WordPress functions. If they’re failing, then they’re likely failing for the reasons described in that thread. Also in that thread are the solutions (namely increase your PHP memory limit).

  18. First off thanks for the awesome plugin. On a side not I think I may have found a bug (as well as a solution to that bug). I posted this in http://wordpress.org/support/topic/failed-to-resize-the-error-message-was-unknown-failure-reason as well, but also thought it might be a good idea to post here.

    In any case my problem was that the the Regen. Thumb plugin uses get_attached_file() to retrieve the filepath. The problem with this is that get_attached_file looks for a post metakey called _wp_attached_file which did not exist. (Not sure why this is the case… perhaps it was because all the content was imported from a non-wordpress blog. Alex any insight into this???). So to get the correct file path I did this:

    In the plugin regenerate-thumbnails.php file (line 352) I replaced

    $fullsizepath = get_attached_file( $image->ID );

    with

    $meta = wp_get_attachment_metadata($image->ID, true);
    $file = $meta['file'];
    $uploads = wp_upload_dir();
    $fullsizepath = $uploads['basedir'] . "/$file";

    And now I can regenerate my images.

  19. Feature Request:

    Not sure if this is within scope of this plugin, but when on the “Add an image” dialog box, and you click the “Edit Image” button, it gives you 3 options to apply your edits to the image. These are:

    Apply changes to:
    -All image sizes
    -Thumbnail
    -All sizes except thumbnail

    It would be nice if there was an option “All customs sizes” or “Featured post thumb” option.

    The reason I post here is because at the moment I make that change, then use this plugin to regenerate the image thumbs so that my custom thumbnails get the new sizes.

    If this is indeed outside the scope of your plugin, Viper could you point me to the right place to request such a feature? I know a bunch of people would like it (http://wordpress.org/support/topic/hack-crop-custom-thumbnail-sizes?replies=17).

    Thanks, keep up the good work!

  20. Still no joy its been two weeks my PHP limit is at like 64M and the plugin still won’t regenerate my thumbnails – it works on every other site I administer and there is no real difference here – I tried deactivating other plugins. The plugin begins working but no progress bar shows up and no images get resized no matter how long i wait. Your plugin is usually amazing but its failed me today…. either that or I’ve done something seriously different from what i usually do?!

  21. Alex,

    I installed your plugin and then the WP-DBManager plugin. When I click on a thumbnail for an image from my media library or from my PhotoShelter archive I receive some rather strange code. Here is a partial list of the code. What do you think is happening?

    Content-language: cs
    Content-type: text/html; charset=ISO-8859-2
    Body:———-cs–

    Po¾adované URL nebylo na tomto serveru nalezeno.

    Zdá se, ¾e odkaz na
    <a href="“>odkazující
    stránce je chybný nebo zastaralý. Informujte, prosím, autora
    <a href="“>této stránky
    o chybì.

    Pokud jste zadal(a) URL ruènì, zkontrolujte, prosím,
    zda jste zadal(a) URL správnì, a zkuste to znovu.


    ———-cs–

    Content-language: de
    Content-type: text/html; charset=ISO-8859-1
    Body:———-de–

    Der angeforderte URL konnte auf dem Server nicht gefunden werden.

    Der Link auf der
    <a href="“>verweisenden
    Seite scheint falsch oder nicht mehr aktuell zu sein.
    Bitte informieren Sie den Autor
    <a href="“>dieser Seite
    über den Fehler.

    Sofern Sie den URL manuell eingegeben haben,
    überprüfen Sie bitte die Schreibweise und versuchen Sie es erneut.


    ———-de–

    Content-language: en
    Content-type: text/html; charset=ISO-8859-1
    Body:———-en–

    The requested URL was not found on this server.

    The link on the
    <a href="“>referring
    page seems to be wrong or outdated. Please inform the author of
    <a href="“>that page
    about the error.

    If you entered the URL manually please check your
    spelling and try again.


    ———-en–

  22. Pingback: » Our favorite WordPress Plug-ins Pattaya Web Services – wesbite design & SEO in Pattaya, Thailand

  23. That’s amazing!! I’m not sure what happened to them, but about half of my thumbnails broke, and your plug in seems to have solved the problem completely, and very easily!!

    Thanks so much!!

  24. Pingback: Website release: Fabmic.ch « //ms-studio.net

  25. is it possible to change this plugin to not only recalc the thumbnails?
    if you work on a photographers page, often large images would be uploaded.
    and the maximum crop of such images in fullsize (page) will also not change after setting other dimensions (max) in wordpress. so would so far i understood this plugin here, just resizes thumbnails and not alle crops like (large, medium)

  26. I am a WordPress newbie, so please bear with me.

    After chaining my thumbnail size in Media options, I installed this plugin on my site and ran it on several photos in my media library. The plugin reported that the resize was successful.

    However, when I load the page with my existing post displaying the existing photo the thumbnail has not resized. Looking at the source code, it is still setting the size to the original thumbnail size.

    I think your plugin is working fine, but somehow my site is still defaulting to the old size.

    Any suggestions? I am running a pretty old WordPress Theme (Freshy2) that may contribute to this.

  27. Pingback: Regenerate Wordpress Thumbnails | Essential Wordpress

  28. I’ve got a photo blog, and I’m trying to create a good backup scheme in case of disaster. For space and convenience reasons I’d like to only back up the original photo and then re-generate all of the thumbnails if I need to restore the site.

    Between my theme and various plugins, there are actually 6 thumbnails generated for each image that I upload, so my question is will this plugin re-generate all 6 of those thumbnails, or only the ones specified under settings>Media?

  29. Hey,

    Just wanted to stop by and leave some huge thanks for saving me hours of time. I created a plugin for my desktop backgrounds website that basically added a ton of custom image sizes to wordpress. Without this plugin I would have been up the creek without a paddle. However, I was able to resize all the images (a few thousand posts) and am now ready to rock and roll :).

    You rock!

    -Dan

  30. Does anyone know how to reverse this process? I saw it is not reversible but says but “you can just change your thumbnail dimensions back to the old values and click the button again if you don’t like the results.” What am I missing? I went to the WP media settings and check the box back for the resize and regenerated and everything stays the same…HELP!

    • My plugin makes sure that thumbnail files exist for all of the thumbnail dimensions that you and your theme have set. So if you have the medium thumbnail setting set to 250×250 pixels, then my plugin makes sure each of your uploads has a 250×250 pixel thumbnail for it. That’s entirely it.

      If you insert a medium sized image into a post, the width/height will be hard-coded into the HTML. Changing settings will not affect that post. My plugin (currently) does not touch posts or anything else either — it only creates thumbnail images.

      I have been playing around with some code that will go through all of your posts and update the HTML for inserted images though (i.e. so when you change settings, you can update the sizes in posts too). Perhaps I should polish it and release it.

      • Yes, yes, yes, please release this code. Or e-mail it to me? I’ve just updated my theme and now everything looks wonky because the videos and images on my old posts are no longer the same size.

      • Ok – here’s my method for updating the images that have already been inserted into posts:
        1) reset your media sizes and run Regenerate Thumbnails
        2) Add this to functions.php

        function new_large_img($vars) {
        	return wp_get_attachment_image($vars[2], $vars[1]);
        }
        
        function new_large_img_filter($content) {
        	$content = preg_replace_callback ( '/<img class="size-(.*?) wp-image-(.*?) .*?\/>/m', 'new_large_img',  $content );
        	return $content;
        }
        
        add_filter( 'the_content', 'new_large_img_filter' );

        3) The last thing I had to do was add some css to fix existing captions:

        .wp-caption {width:auto !important;}

        Hopefully this helps someone… It’s a nice solution since it’s non destructive to your posts in the database.

  31. Pingback: testing | 5coins

  32. Pingback: Remove all resized WordPress media images

  33. i was told to try this plugin to force wordpress to use an edited thumbnail that is cropped to a different place than the default is choosing, and that it would make wordpress use the edited crop. but it’s not doing that. i continue to see the default thumbnail. is your plugin able to do that, or only resize them?

      • ahh thanks Alex, appreciate the quick reply to. i will keep your plugin in mind if i ever need that and look for something else to sort out my problem 🙂

  34. I ran the plugin and see no changes, to the site.
    is there a step i am missing, like after regenerate thumnails?
    do i need to manually replace the thumnails?

    it is not changing the posts.

    mcmnerd.com

    • Posts contain hard-coded references to specific thumbnail sizes. My plugin does not currently go through all of your posts and update those references.

      Featured image, gallery thumbnails, and other dynamically generated HTML is what gets affected by this plugin.

  35. Pingback: Regenereaza pozele din Wordpress - dexblog.ro

  36. Pingback: Images Help - Please.. « Cosmothemes

  37. Pingback: My Favorite Plug-ins / Michigan Freelance Web Designer

  38. Hi

    Can you give me some advice about troubleshooting this great plugin on a Windows Server 2003 box as I have the plugin running with no errors but the images don’t appear to be resized?

      • Thanks for quick reply Alex – once I typed all that out I went and investigated general image resize issues on Windows and realised I needed to change the php.ini on the Windows box to allow the php_gd2.dll extension by uncommenting:

        extension=php_gd2.dll

      • Note: The small patch might need some polishing, it has to be more ‘intelligent’, with the current pattern for glob(), another check before unlink() should be there.

        Why?

        If there are filenames like file1.jpg (file1-120×120.jpg …) and file1-2.jpg (file1-2-120×120.jpg …) and we use the patch for file1.jpg, glob() with current pattern will also return the thumbs of file1-2.jpg as the pattern fits there as well.

          • I really need a good code to remove all the old thumbnails I have created but I have files like this-is-my-file.jpg too, so I need a really secure method of deleting the old thumbnails. Can you help?

            • That’s not true. When you regenerate the thumbnails, it overwrites the existing ones. The only new files are any thumbnails in any new sizes that you’ve added. Deleting old thumbnails would only free up space from thumbnail sizes that you no longer use, and it could very easily cause broken images in posts.

Comments are closed.