Every time an image is uploaded to WordPress, the server generates multiple scaled versions of it, thumbnail, medium, large, medium_large, 1536×1536, 2048×2048, in addition to keeping the original. With default settings, a single uploaded image can result in six or more files on disk. For a site with hundreds or thousands of images, this adds up to significant storage overhead. Many of these generated sizes are never actually referenced in any template or post content.
This snippet removes specific generated sizes from the upload process and optionally prevents WordPress from scaling down very large originals, giving you control over exactly what gets stored.
The Code
Add this to your functions.php or a site-specific plugin. The intermediate_image_sizes_advanced filter receives an array of all sizes that WordPress is about to generate and returns the modified array. Any sizes you unset() won’t be generated for future uploads.
Which Sizes to Remove
The three sizes removed in the snippet are the most commonly unnecessary ones:
medium_large is a 768-pixel-wide size added in WordPress 4.4 for use in responsive images via the srcset attribute. It’s useful if your content area is around that width, but many themes never reference it directly. Check your theme’s image size usage before removing it.
1536x1536 and 2048x2048 were added in WordPress 5.3 as retina-targeting sizes for high-DPI screens. They’re large files, often several megabytes each, and are rarely needed unless your site displays images at very large sizes on high-resolution displays. For most sites they represent pure storage waste.
To determine which sizes your theme actually uses, search your theme files for get_the_post_thumbnail, wp_get_attachment_image, and add_image_size calls. Any size not referenced in your theme or active plugins is a candidate for removal.
The Big Image Threshold
WordPress 5.3 introduced a feature that automatically scales down uploaded images larger than 2560 pixels wide or tall, storing the scaled version as the “original” and keeping the true original as a backup. The big_image_size_threshold filter controls this threshold. Setting it to false via __return_false disables the scaling entirely, preserving uploaded images at their original dimensions.
Disable this threshold if you need full-resolution originals preserved for editorial or print use. Keep it enabled if your site never needs images larger than 2560px and you prefer WordPress to manage the storage impact of very large uploads automatically.
Existing Images
Removing a size from the filter stops it from being generated for new uploads, it doesn’t delete the already-generated versions of existing images. To reclaim disk space from previously generated sizes, you’d need to either manually delete the files or use a plugin that cleans up unused image files. Running Regenerate Thumbnails after adding this snippet will regenerate existing images without the removed sizes going forward.
add_filter( 'intermediate_image_sizes_advanced', function( $sizes ) {
// Remove sizes your theme and plugins don't use
unset( $sizes['medium_large'] ); // 768px, rarely used directly
unset( $sizes['1536x1536'] ); // 2x retina, only needed for high-DPI displays
unset( $sizes['2048x2048'] ); // 4x, almost never needed
return $sizes;
} );
// Prevent WordPress from scaling very large originals down to 2560px
add_filter( 'big_image_size_threshold', '__return_false' );
