Fall Sale! Code FALL2024 takes 25% OFF our Pro Plugins & Books »
Web Dev + WordPress + Security

How to Disable WordPress Automatically Generated Images – Complete Guide

[ WordPress Image Sizes ] As you may know, WordPress creates numerous copies of all images uploaded via the WP Media Library. These additional images are generated in various sizes, depending on your settings and other factors. This may be totally fine in general, but if you are working with lots of images on your site, the extra files can really eat up your disk space. This can be wasteful, specially if your site does not make use of all the extra images. So to help you conserve resources, eliminate waste, and keep things running as light as possible, this guide spells out everything you need to disable (or customize) all WordPress automatically generated images.

Update! New plugin available to give you control over which media sizes are generated by WordPress. Check out Disable Media Sizes at the Plugin Directory.

Learn how to disable any/all of WordPress’ auto-generated images to dial in the perfect configuration for your site.

Contents

First an example..

To get a better idea of what’s happening and why it’s important, consider my personal found-images site, eChunks.com. This site is where I like to post weird/inspiring/found images. As of now, there have been over 800 images uploaded to the site via the WP Media Library. So if I hadn’t taken measures to stop WordPress from auto-generating multiple copies of each image, that number of 800 would be more like thousands of images.

Do the math..

So running with the eChunks.com example, let’s do some quick math. We have a WordPress site with 800 original images, each averaging around 2MB in size. So collectively the original 800 images weigh around 1,600 MB or about 1.6 GB. Now let’s let WordPress do its thang and create extra copies of each image in various sizes. As of version 5.3, WordPress creates the following extra images for every image that is uploaded via the Media Library (and/or Visual Editor):

Image Size Dimensions
Thumbnail (Size based on Media settings)
Medium (Size based on Media settings)
Large (Size based on Media settings)
Medium Large 768px
2x Medium Large 1536px
2x Large 2048px
Scaled 2560px

Okay so now to get an idea of actual file-sizes for all these generated images, let’s consider the average case where each of the 800 original images weighs around 1.5MB to 2MB. The results would look something similar to this:

Image Size Dimensions File Size Total
Thumbnail (Size based on Media settings) 10KB 8MB
Medium (Size based on Media settings) 20KB 16MB
Large (Size based on Media settings) 100KB 80MB
Medium Large 768px 50KB 40MB
2x Medium Large 1536px 200KB 160MB
2x Large 2048px 400KB 320MB
Scaled 2560px 500KB 400MB

Adding that right column gives a grand total of 1024MB or 1.024 Gigabytes! Considering that the entire WordPress core weighs in at less than 50MB, along with a bunch of plugins and themes is still gonna be less than a couple hundred megabytes. So relative to the entire website, the amount of disk space required by all of those extra images is considerable to put it mildly.

And that’s for a typical site with only 800 images; some sites make use of a LOT more than that, not to mention high-resolution images and images that weigh a lot more than the average numbers used in the previous calculations. So it’s easy to understand, if WordPress generated images are not kept in check, the amount of required disk space can really add up.

But wait there’s more..

So far we’ve got WordPress generating seven additional images for each original uploaded image. But that’s not all of the extra images that may be in play. Depending on your theme, even more additional image sizes may be created via the following WordPress core functions:

  • set_post_thumbnail_size() — Creates a custom size for Featured Images
  • add_image_size() — Creates extra images of any specified size(s)

For example the WordPress default theme named “Twenty Fifteen” adds another extra generated image with this line:

set_post_thumbnail_size( 825, 510, true );

So that one extra image, plus the seven other default generated images, plus the original uploaded image, all looks like this on the server:

[ WordPress image files on server ]In addition to the seven extra images generated by WordPress, extra images may be added by your theme, as shown here for the Twenty Fifteen theme.

To summarize: WordPress generates at least 7 extra image sizes for each uploaded image. And then depending on your theme and plugins, any number of additional image sizes may be created as well. For some sites, this is useful or no big deal; for other sites, it’s something that’s completely unnecessary at best, wasteful overkill at worst.

Solution: Disable unwanted image sizes

The above scenario is only one example to illustrate the point. The sum total of image weight could be (much) more or less depending on your images, media settings, theme functions, and so forth. Fortunately, I continually disable the new WordPress image sizes that are added over the years, so I’ve been able to avoid massive disk bloat on my own sites.

So what’s the solution? How to manage all those extra images and conserve disk space? The trick is understanding how to disable each of the extra image sizes, so you can add the required code to disable (or customize) the ones that are not needed. Here are the magic recipes for controlling them:

Caution: Do not disable any image sizes that are required by your theme!

Disable Thumbnail Size

To disable generation of thumbnail-size images, set the “Thumbnail size” option to “0” (under Settings > Media > Image sizes). Setting to “0” disables auto-generation of this size image. Set to any other value to customize the size instead of disabling. Here is what the setting looks like under the Settings menu in the WP Admin Area:

[ WordPress Media Settings ]To disable or customize Thumbnail, Medium, and Large size images, visit this screen in the WP Admin Area. Enter “0” (without the quotes) to disable any/all of these extra size images.

Alternately, if you prefer to disable the thumbnail-size images programmatically, you can add the following code snippet to your theme functions.php (or add via simple/custom plugin):

function shapeSpace_disable_thumbnail_images($sizes) {

	unset($sizes['thumbnail']); // disable thumbnail size
	return $sizes;

}
add_action('intermediate_image_sizes_advanced', 'shapeSpace_disable_thumbnail_images');
Tip: the above technique can be used to disable other image sizes, as shown in some of the following techniques. So you can combine some of the size-disabling techniques into one single code snippet.

Disable Medium Size

To disable generation of medium-size images, set the “Medium size” option to “0” (under Settings > Media > Image sizes). Setting to “0” disables auto-generation of this size image. Set to any other value to customize the size instead of disabling.

Alternately, if you prefer to disable the medium-size images programmatically, you can add the following code snippet to your theme functions.php (or add via simple/custom plugin):

function shapeSpace_disable_medium_images($sizes) {
	
	unset($sizes['medium']); // disable medium size
	return $sizes;

}
add_action('intermediate_image_sizes_advanced', 'shapeSpace_disable_medium_images');

Disable Large Size

To disable generation of large-size images, set the “Large size” option to “0” (under Settings > Media > Image sizes). Setting to “0” disables auto-generation of this size image. Set to any other value to customize the size instead of disabling.

Alternately, if you prefer to disable the large-size images programmatically, you can add the following code snippet to your theme functions.php (or add via simple/custom plugin):

function shapeSpace_disable_large_images($sizes) {
	
	unset($sizes['large']); // disable large size
	return $sizes;
	
}
add_action('intermediate_image_sizes_advanced', 'shapeSpace_disable_large_images');

Disable Medium Large

To disable the “Medium Large” size images, add the following code snippet to your theme’s functions.php file:

function shapeSpace_disable_medium_large_images($sizes) {
	
	unset($sizes['medium_large']); // disable 768px size images
	return $sizes;
	
}
add_filter('intermediate_image_sizes_advanced', 'shapeSpace_disable_medium_large_images');

Disable 2x Medium Large

To disable the “2x Medium Large” size images, add the following code snippet to your theme’s functions.php file:

function shapeSpace_disable_2x_medium_large_images($sizes) {
	
	unset($sizes['1536x1536']); // disable 2x medium-large size
	return $sizes;
	
}
add_filter('intermediate_image_sizes_advanced', 'shapeSpace_disable_2x_medium_large_images');

Disable 2x Large

To disable the “2x Large” size images, add the following code snippet to your theme’s functions.php file:

function shapeSpace_disable_2x_large_images($sizes) {
	
	unset($sizes['2048x2048']); // disable 2x large size
	return $sizes;
	
}
add_filter('intermediate_image_sizes_advanced', 'shapeSpace_disable_2x_large_images');

Disable Scaled

To disable the “Scaled” images, add the following code snippet to your theme’s functions.php file:

add_filter('big_image_size_threshold', '__return_false');

Disable Other Sizes

For any extra images generated via set_post_thumbnail_size() and add_image_size(), you can use remove_image_size(). Here is an example:

function shapeSpace_disable_other_images() {
	
	remove_image_size('post-thumbnail'); // disable set_post_thumbnail_size() 
	remove_image_size('another-size');   // disable other add image sizes
	
}
add_action('init', 'shapeSpace_disable_other_images');

The key here is to know the name/slug of the custom image sizes you want to remove. For set post thumbnail (i.e., Featured Image), it’s always post-thumbnail. For other images added via add image size, the slug name will vary depending on your theme or plugin (whichever is responsible for adding the extra sizes). So to implement, first check your uploads directory and/or theme functions file to determine which sizes are being generated. Some themes add a bunch of extra image sizes, others do not, it just depends on the theme.

Pro Tip: Get a list of all registered image sizes for your WordPress site.

Shut them all down!

Before our parting shot, here is an “all-in-one” code snippet that combines and streamlines all of the above techniques into a single, plug-&-play code snippet:

// disable generated image sizes
function shapeSpace_disable_image_sizes($sizes) {
	
	unset($sizes['thumbnail']);    // disable thumbnail size
	unset($sizes['medium']);       // disable medium size
	unset($sizes['large']);        // disable large size
	unset($sizes['medium_large']); // disable medium-large size
	unset($sizes['1536x1536']);    // disable 2x medium-large size
	unset($sizes['2048x2048']);    // disable 2x large size
	
	return $sizes;
	
}
add_action('intermediate_image_sizes_advanced', 'shapeSpace_disable_image_sizes');

// disable scaled image size
add_filter('big_image_size_threshold', '__return_false');

// disable other image sizes
function shapeSpace_disable_other_image_sizes() {
	
	remove_image_size('post-thumbnail'); // disable images added via set_post_thumbnail_size() 
	remove_image_size('another-size');   // disable any other added image sizes
	
}
add_action('init', 'shapeSpace_disable_other_image_sizes');

That code snippet combines all of the techniques required to disable all of WordPress generated images (leaving only the original uploaded image). The only editing that may be required is for that last function, where “other” image sizes are disabled; there you may want to edit the another-size slug to match any other sizes that you want to disable, or if there are no other sizes, simply comment out or remove the line.

Pro Tip: In addition to all the extra images generated by WordPress, you may also want to control or disable all of the extra responsive image functionality that WordPress provides. Here is a free plugin to make it super easy: Disable Responsive Images Complete.

Wrap it up..

Granted, controlling WordPress image sizes may be more important for sites with a lot of images. But even if your site only uploads a few images every now and then, keeping your files as simple and lightweight as possible makes for a leaner, faster, more optimized WordPress-powered website.

About the Author
Jeff Starr = Creative thinker. Passionate about free and open Web.
Blackhole Pro: Trap bad bots in a virtual black hole.

13 responses to “How to Disable WordPress Automatically Generated Images – Complete Guide”

  1. A better way to disable thumbnail, medium and large sizes is set the dimensions to 0 in the settings.

  2. JEFF

    Thanks for the article.

    Alas, I am uncertain as to what I should do as the whole image-generation thing in WordPress has baffled me.

    On my sites, I set images to the following sizes in my posts:

    300 px
    600 px
    1500 px

    Plus the itty-bitty images on my posts list.

    If I use a size other than those, I set the Add Media to Full Size.

    So, which of the sizes that WordPress is needlessly generating should I disable?

    NEAL

    • Jeff Starr 2019/12/02 9:00 am

      Hi Neal, if in doubt only disable the newer image sizes that are not explicitly used by your theme. I am guessing that the new 2x medium-large, 2x large, and Scaled sizes may not have been used by your theme as they were introduced just a few weeks ago. So probably safe to disable those larger sizes. Plus it doesn’t sound like you are using the medium-large size, so may want to look at that one as well.

      • JEFF

        Thanks for the quick response! Two more questions:

        1. Will the snippets eliminate already existing unwanted images?

        2. I use the ShortPixel Adaptive Images plugin. Are there any know conflcits between it and the snippets?

        Best,

        NEAL

      • Hi Neal, glad to help:

        1) No, the techniques in the article only work on new uploaded images (that are added after the snippets are in place). They do not affect any existing images.

        2) I’m not familiar with that particular plugin, but can assure you that the techniques are WP API, part of core WP functionality. If unsure drop a post in the plugin help forum, they should be able to help answer any questions.

  3. Hey Jeff,

    Thank you for your great write-up and I really agree about those image sizes taking up too much space.

    And like you say, your theme and plugins may add more image sizes than WordPress itself. I recently worked on a site which started to run out of hosting space because of all those image sizes.

    There’s also a plugin called ‘Stop Generating Image Sizes’, that can do this in a graphical interface, but it hasn’t been updated for a while. And I love that you’ve put the code all together to drop into functions.php, because that means we don’t have to install a plugin.

    At them same time the plugin I mentioned detects all image sizes (including any extra ones that might be added by other plugins), which maybe makes it an easier and more complete solution in some cases.

    • Thanks for the feedback, Dave. I will have a look at the Stop Generating Image Sizes plugin and maybe see about adopting and updating it. Cheers.

  4. Nice work, Loved your plugin.

    Thanks for the help ..

  5. Thank you! ‘Shut em down’ saved me a ton of time!

  6. Kristian Adolfsson 2020/01/14 5:40 am

    Hi Jeff

    Great article as usual!

    There are more problems with the 5.3 update, though. It’s not just that it creates more sizes, it actually UPSCALES your images to the larger sizes.
    I upload my largest images as max 1250px vert or 850px hor.
    WP then upscales them to the 1526px and 2048px sizes with a really bad result, of course.

    I feel this is a glaring bug!! It doesn’t check the original size. Not everybody uploads 20 MB images at full resolution.

    One example: original image is 156 kB (1130px x 850px), WP then adds 638 kB of UPSCALED images that are useless. This is redicolous! A guesstimate is it adds between 3.5 and 5.5 times the size in uploads.

    –Further experiments
    I use a plugin called “Force Regenerate Thumbnails” to regenerate the images. It regenerates all the new sizes and deletes the ones you don’t use anymore. I use Beaver Builder Theme that adds no image sizes.
    I ran it on one of my sites after 5.3 and these are the stats:

    806 images on the site
    a total of 4849 files (895 MB) in the upload dir. That’s just over 6 files per image on average. Please note I’ve already turned off Large size by setting to 0 x 0, so it could have been 7!.

    After implementing the codes below on my site and running Regenerate again (I get no Scaled images for some reason):

    unset($sizes['medium_large']);	
    unset($sizes['1536x1536']);
    unset($sizes['2048x2048']);

    2428 files and 161 MB!!!! 730 MB of unused (and some useless) files created by 5.3.

    Thoughts?

    • Jeff Starr 2020/01/14 9:27 am

      Hi Kristian, it definitely is a bug: WP should not be upscaling images; rather, the size of the original image should be considered the maximum size, such that only smaller images are generated. Upscaling is a bad idea because there is not enough data to compensate for the extra added area, so you end up with images that look blurry and just really bad as you point out.

      So thanks for sharing this information. It looks like disabling the larger sizes prevents upscaling to those sizes, which is yet another benefit of disabling the extra generated images. Thanks for the feedback.

      • Kristian Adolfsson 2020/01/27 9:35 pm

        Hi Jeff
        Another benefit is the time it takes to upload the images. I use Media Library Assistant plugin to setup my Captions, Alt tags etc. and wit just s few sizes to generate of course it is now “lightning” fast.

        Have you reported the bug?

Comments are closed for this post. Something to add? Let me know.
Welcome
Perishable Press is operated by Jeff Starr, a professional web developer and book author with two decades of experience. Here you will find posts about web development, WordPress, security, and more »
BBQ Pro: The fastest firewall to protect your WordPress.
Thoughts
Went out walking today and soaked up some sunshine. It felt good.
I have an original box/packaging for 2010 iMac if anyone wants it free let me know.
Always ask AI to cite its sources.
All free plugins updated and ready for WP 6.6 dropping next week. Pro plugin updates in the works also complete :)
99% of video thumbnail/previews are pure cringe. Goofy faces = Clickbait.
RIP ICQ
Crazy that we’re almost halfway thru 2024.
Newsletter
Get news, updates, deals & tips via email.
Email kept private. Easy unsubscribe anytime.