Regenerate Thumbnails
How to delete old thumbnail images (5 posts)

  1. ezhil
    Posted 5 years ago #

    hi viper,
    regenerate thumbnail is a great plugin and it helps big time in my project. However, i need to delete the delete the old thumbnails, which are previously generated.
    we change our theme often and according to our needs the thumbnail size would also be changed(drastically), so i need to delete the old thumbnail images previously generated using the plugin.
    currently i do it manually by accessing my cpanel, is their any other way to do it.

  2. Ov3rfly
    Posted 4 years ago #

    Regenerate Thumbnails - Version 2.2.0

    In file regenerate-thumbnails.php locate this, at line 357:

    @set_time_limit( 900 ); // 5 minutes per image should be PLENTY
    $metadata = wp_generate_attachment_metadata( $image->ID, $fullsizepath );

    Add this block of code between the two lines:

    @set_time_limit( 900 ); // 5 minutes per image should be PLENTY
    // find and delete any previous image-sizes
    $info = pathinfo($fullsizepath);
    $ext = $info['extension'];
    $pattern = str_replace(".$ext", "-*x*.$ext", $fullsizepath);
    foreach (glob($pattern) as $filename) {
    $metadata = wp_generate_attachment_metadata( $image->ID, $fullsizepath );

    This will delete any previously generated image-sizes, including older outdated sizes before creating the new sizes.

    Important: Note that URLs to images are hard-coded in posts and pages. Removing old thumbnails could result in broken images if they are still used somewhere on your site. You have been warned...


  3. Ov3rfly
    Posted 4 years ago #

    Find more details in forum of plugin-developer...

  4. nicearma
    Posted 4 years ago #

    You can try with this plugin DNUI

  5. afublog
    Posted 4 years ago #


    Your code will be fail if I have an image which has the following name:


Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Regenerate Thumbnails
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic