How To Stop WordPress From Generating So Many Additional Image Sizes

One look inside your WordPress uploads directory and you’ll see 5 to 7 generated images not including your original.  Maybe you have a complex theme and you really need all those size variation, but probably not.  If your original image size is 4 MB and the 7 other variations of that image equal a combined 2 MB, you will eventually be using up a lot of server space.  Backups are probably taking forever.  Are they all necessary for your needs?

In our scenario, we only want two image variations. Our original image (but resized to 850 px wide) and images uploaded via Media for insertion into posts or used as the featured image at 450 pixels wide.

  1. Under Settings > Media set all image size values to zero
    1. This will remove the thumbnail, medium, and large size
  2. To get rid of the medium_large  image size, add the following to your functions.php file
    1. add_filter( 'intermediate_image_sizes', function( $sizes )
      {
          return array_filter( $sizes, function( $val )
          {
              return 'medium_large' !== $val; // Filter out 'medium_large'
          } );
      } );

       

  3. To reduce the size of your original images as they are uploaded, you will need a plugin.  We use EWWW Image Optimizer, which is automatically included with the A2 Optimized plugin.  Under Settings > EWWW Image Optimizer, click on the Resize tab and set the maximum width and height for uploaded images.
  4. Depending on your theme, you may need to also remove any theme-specific sizes.  These would be located within the functions.php file.