19

I've been looking around the net for a long time on how to disable WordPress from creating multiple thumbnails.

I've seen in most tutorials to set all the images to 0 in the media section. I have done that, but going to my uploads folder and it still creates multiple images.

I can't find any solution for this. The reason I want this is to save space on my host account.

2
  • Please turn off any plugins and switch to your default theme. Then you should be able to set all image sizes to 0 and keep WP from generating those sizes. If this doesn't work, please report back. If it works, then there's some plugin or theme interfering.
    – kaiser
    Mar 17, 2013 at 11:33
  • You can use the plugin Stop Generating Unnecessary Thumbnails. WordPress doesn't generate thumbnail when uploading images or set featured image and image doesn't make image cropping with folder image upload where make add size or number of files hosting. Jul 27, 2021 at 2:12

9 Answers 9

14

To built on Max Yudin's answer you should use the intermediate_image_sizes_advanced filter, and not image_size_names_choose. Add to functions.php

function add_image_insert_override($sizes){
    unset( $sizes['thumbnail']);
    unset( $sizes['medium']);
    unset( $sizes['large']);
    return $sizes;
}
add_filter('intermediate_image_sizes_advanced', 'add_image_insert_override' );

Another easier option I think works is going to your Settings-->Media and setting each box for width and height to 0

0
13

You can also filter intermediate_image_sizes with an empty array.

 add_filter( 'intermediate_image_sizes', '__return_empty_array' );
4

Visit the Settings > Media page of your WordPress dashboard. Under the Image Sizes section, change all of the values to 0.

Media Settimgs

Save the changes. This will stop WordPress generating thumbnails, medium, and large sizes of every image you upload.

You will also notice that when you go to insert an image, the "Size" dropdown box is missing.

2
  • 2
    This does not work! Sep 11, 2014 at 13:07
  • @Pazis It worked in an older version of WordPress, but doesn't seem to work in 4.0
    – shea
    Sep 12, 2014 at 6:15
3

If I remember right you have to unset all the defaults and add the new Size there:

    <?php
function mxdCustomImageSizes($sizes) {
    unset( $sizes['thumbnail']);
    unset( $sizes['medium']);
    unset( $sizes['large']);
    unset( $sizes['full'] );

    $myimgsizes = array(
        'full-size' => __( 'Full Size' )
    );
    if( !empty($sizes) )
        return array_merge($sizes, $myimgsizes);
    else
        return $myimgsizes;
}
add_filter('intermediate_image_sizes_advanced', 'mxdCustomImageSizes');

And then add the full-size size which is 99999x99999 right below which size is almost unbelievable so is full size.

add_image_size( 'full-size', 99999, 99999, false );

Please correct me if something goes wrong

P. S. You'll need a plugin to "save as" all your images according to your new settings. I can recommend the Regenerate Thumbnails plugin.

P. P. S. When it's the single Option any way you'll have to choose one of one :). There no straight way to make one Size selected in the new (3.5.1) Media window.

2
  • Hi Max I think this is the wrong filter, image_size_names_choose is for the output when you select images in the media box.
    – Wyck
    Mar 16, 2013 at 16:15
  • Yes, you are right. Thank you for information, now I have to revise some stuff I've already made.
    – Max Yudin
    Mar 17, 2013 at 19:03
2

For the latest WordPress with WooCommerce activated plugin use this code:

function add_image_insert_override($sizes){
    unset($sizes['thumbnail']);
    unset($sizes['medium']);
    unset($sizes['medium_large']);
    unset($sizes['large']);
    unset($sizes['1536x1536']);
    unset($sizes['2048x2048']);        
    unset($sizes['blog-isotope']);
    unset($sizes['product_small_thumbnail']);
    unset($sizes['shop_catalog']);
    unset($sizes['shop_single']);
    unset($sizes['shop_single_small_thumbnail']);
    unset($sizes['shop_thumbnail']);
    unset($sizes['woocommerce_thumbnail']);
    unset($sizes['woocommerce_single']);
    unset($sizes['woocommerce_gallery_thumbnail']);
    return $sizes;
}
add_filter('intermediate_image_sizes_advanced', 'add_image_insert_override' );
add_filter('max_srcset_image_width', create_function('', 'return 1;'));

But it would be great if you leave one small thumbnail (thumbnail) and one middle-sized image (medium).

P.S. You can see all registered sizes by installing Regenerate Thumbnails plugin. And don't forget about add_image_size() generating on the theme side.

0
1

If you want to remove everything just returns an empty array.

function remove_thumbnail_image_sizes($sizes) {
    return [];
}
add_filter('intermediate_image_sizes_advanced','remove_thumbnail_image_sizes');
1
  • Yes, that's what Chris O's answer is doing, but on the not-advanced hook and using the built-in __return_empty_array function.
    – Rup
    Nov 30, 2021 at 10:53
0
function remove_default_image_sizes( $sizes) {
    unset($sizes['thumbnail']);
    unset($sizes['medium']);
    unset($sizes['large']);
    return $sizes;
}
add_filter('intermediate_image_sizes_advanced','remove_default_image_sizes');

Don't forget to return $sizes; like this.

Then add new image sizes like...

if(function_exists('add_image_size')){
    add_image_size('my_100x100_crop',100,100,true); // Crop mode
    add_image_size('my_100x100_resize',100,100); // Resize mode
}

Tested!

1
  • 1
    This removes the sizes from "Insert to post", but Wordpress still generates the thumbnails! Sep 11, 2014 at 13:05
0

I've run into trouble using the intermediate_image_sizes_advanced filter on a few sites lately. It seems like in WP 5.3 intermediate_image_sizes is more reliable.

I would recommend unsetting unwanted sizes like this:

add_filter('intermediate_image_sizes', 'remove_default_img_sizes', 10, 1);

function remove_default_img_sizes($sizes)
{
    $targets = ['medium', 'medium_large', 'thumbnail'];

    foreach ($sizes as $size_index=>$size) {
        if (in_array($size, $targets)) {
            unset($sizes[$size_index]);
        }
    }

    return $sizes;
}
0

Since Wordpress often have WooCommerce installed this disables the image regeneration when put into a functions.php (for example in a child theme or via a code snippet plugin since it may otherwise be overwritten on updates).

add_filter( 'woocommerce_background_image_regeneration', '__return_false' );
2
  • Does that actually turn off image regeneration, or does it just mean don't do it in the background but it will still happen in the foreground?
    – Rup
    Nov 10, 2021 at 21:57
  • That's a great question, I will do a check of what actually shows up in the media folder(-s) on the server and try to update my answer in case. Nov 11, 2021 at 8:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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