Join Digital Nomads and Remote Workers to Ask Questions, Share Experiences, Find Remote Jobs and Seek Recommendations.

Disable Unwanted Image Sizes Generation in WordPress

Do you know that every single time you upload an file to your WordPress size. The WordPress will automatically generate a tons of images without your notice? If you are notice about it and yes, I’ve came over with solutions.

To stop WordPress from generating the Images, you need to use a child theme and add it to your child theme function.php file.

// Disable WordPress and Woocommerce Image Sizes
function disable_wp_image_sizes( $sizes ) {
    unset( $sizes['thumbnail'] );
    unset( $sizes['medium'] );
    unset( $sizes['medium_large'] );
    unset( $sizes['large'] );
    unset( $sizes['1536x1536']);
    unset( $sizes['2048x2048']);
  
    // WooCommerce Image Size
    unset( $sizes['woocommerce_thumbnail'] );
    unset( $sizes['woocommerce_single'] );
    unset( $sizes['woocommerce_gallery_thumbnail'] );
    unset( $sizes['shop_catalog'] );
    unset( $sizes['shop_single'] );
    unset( $sizes['shop_thumbnail'] );
    return $sizes;
}
add_filter('intermediate_image_sizes_advanced', 'disable_wp_image_sizes');
// Disable Scale Image Sizes
add_filter('big_image_size_threshold', '__return_false');
 
// Disable Other Image Sizes
function disable_wp_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', 'disable_wp_other_image_sizes');

Once you have place the code to the function.php, don’t forget to save it. It will works immediately, I have test it with latest version of WordPress 6.2.

Why Disable Unwanted Image Sizes Generation In WordPress

Disabling unwanted image sizes in WordPress can help your website to load faster, and also reduce the amount of disk space used to store image files. By default, WordPress generates several image sizes for each image you upload, which can lead to a bloated media library and slow down your website’s performance.

If you have a theme or plugin that uses custom image sizes, you can still generate those, but disabling the unwanted sizes can save you time, bandwidth, and storage space. Reducing the number of unnecessary image sizes can help your backups run faster and take up less space on your server.

Benefits of Disable Unwanted Image Sizes Generation In WordPress

There are several benefits to disabling unwanted image sizes generation in WordPress:

  1. Improved website speed: By reducing the number of images your website needs to load, you can significantly improve loading times. This can be especially important for mobile users who may be on slower connections.
  2. Reduced server load: By generating fewer images, your website will consume less server resources, which can help reduce hosting costs and improve overall site performance.
  3. Lower storage requirements: By generating fewer images, you’ll also reduce the amount of storage space required for your media library. This is especially useful if you have a lot of images on your site or limited disk space.
  4. Reduced backup size: By generating fewer images, your backups will be smaller and faster to create, which can be especially important if you’re backing up frequently.
  5. Improved SEO: Faster loading times can improve your website’s search engine optimization (SEO) by increasing the likelihood that users will stay on your site, reducing bounce rates, and increasing engagement.

We Work From Anywhere

Find Remote Jobs, Ask Questions, Connect With Digital Nomads, and Live Your Best Location-Independent Life.