woman typing on her computer with plant in the foreground

How to Prevent WordPress From Generating Image Sizes

When you upload an image to WordPress, it generates three image sizes by default (thumbnail, medium, and large). However, there may be times when you want to use custom image sizes, either for design purposes or to manage your site’s performance.

While WordPress compressing images automatically is meant to be a convenience, it can end up creating too many files that take up unnecessary storage, and lead to backups that are too large. Fortunately, there are steps you can take to prevent this from happening.

In this post, we’ll answer the question: “Why does WordPress resize my images?” We’ll explain why you might want to stop WordPress from generating multiple image sizes, and show you how to do it. Let’s get started!

Why WordPress Generates Multiple Image Sizes

Put simply, WordPress automatically resizes images to help you save bandwidth and prevent you from having to manually resize images. For example, the image size you would use for a thumbnail is much different than what you would use for an image slider on your home page. By generating multiple image sizes, WordPress makes it easier for you to select the most appropriate option for each use case.

When to Stop WordPress From Generating Different Image Sizes

In addition to the image sizes generated by WordPress, your theme may also create copies or additional image sizes, such as for a home page slideshow or featured posts. This redundancy can present issues, such as causing your backups to take longer or your pages to load more slowly.

For that reason, there are times when preventing WordPress from generating different image sizes is beneficial. If you’re looking to save space, have an image-heavy website such as a real estate or photography site, or simply aren’t using all of the image sizes that are being created, you may be adding extra bulk to your site for no reason.

How to Stop WordPress From Generating Different Sized Image Copies

Now that you understand why WordPress generates multiple image sizes, and why it makes sense to prevent it from doing so, it’s time to get to work. Let’s take a look at how to stop WordPress from generating different image sizes in six simple steps.

Step 1: Connect Your Site to an FTP Client (To Determine How Many Images Copies Are Being Made)

The first step is to figure out how many copies WordPress is generating when you upload an image. You can do this by connecting to your site via a FileTransfer Protocol (FTP) client or your cPanel’s file manager.

As we mentioned earlier, WordPress generates three copies by default. However, your theme may also create its own set of image sizes for sliders, etc. So it’s important to know exactly what copies are being generated.

Step 2: Upload an Image to Your Site

Next, upload an image to your site from your WordPress admin area (Media > Add New):

Upload image to WordPress

Click on Select Files, and then choose the image to upload.

Step 3: Navigate to Your Site’s Upload Directory

Within your File Manager or FTP client, navigate to your site’s ‘upload’ directory. This will be located within the wp-contents folder. There, you’ll find all the copies of your images, which are organized by date:

WordPress site upload directory

At the least, you should find the three image sizes generated by WordPress. If there are more than three, they are likely the copies created by your WordPress theme (in our example above, there are five copies in total).

Step 4: Set Image Sizes to Zero

Next, navigate to Settings > Media in your WordPress admin dashboard:

Settings > Media in WordPress admin dashboard

There, you’ll find the default image settings:

WP Admin default image settings

Change each of the values for the image sizes to 0 (assuming that they are all ones you won’t be using). Select the Save Changes button at the bottom of the page when you’re done.

Step 5: Open the functions.php File of Your WordPress Theme

You’ve now stopped WordPress from generating multiple copies of the images you upload. However, you may also need to stop your theme from doing the same thing.

To do that, navigate to the functions.php file for your WordPress theme:

functions.php file in WordPress theme

You’ll find this in the /wp-contents/themes/ folder of your website’s directory. 

Step 6: Delete the Default Image Size Code 

Once you’re in the functions.php file, look for any lines of code that are similar to this one:

add_image_size( ‘homepage-thumb’, 200, 160, true );

Depending on the theme you’re using, there may be multiple versions of this line. You’ll also want to look for any that say “set_thumbnail_post_size”. Remove these lines, and then save your changes.

How to Stop WordPress From Compressing Images

Along with preventing WordPress and your theme from generating multiple images sizes, you can also prevent them from compressing images. While compression is meant to enhance performance without reducing quality, this isn’t always the case.

With that in mind, here’s how to stop WordPress from compressing and cropping images in three simple steps.

Step 1: Open the functions.php File

If you want to disable WordPress image compression, the first step is to locate and open your theme’s functions.php file. Again, you can do this by connecting to your site via an FTP client, or by accessing your cPanel’s File Manager. 

Step 2: Modify the Return Value to 100

After you locate and open the functions.php file in your theme directory, simply add the following line of code:

add_filter(‘jpeg_quality’, function($arg){return 100;});

You can also change the ‘return’ value to be less than 100 if you prefer.

Step 3: Save Your Changes

Once you’re done, save your changes. Now WordPress will stop automatically compressing images, and instead retain their original quality. Note that in order to see the effect take place, you’ll need to regenerate your thumbnails

Keep Your Site Optimized With WP Engine

By default, WordPress automatically generates multiple image sizes during the upload process. However, when you’re using a theme or plugins that also create copies of your images, this can lead to unnecessarily large backups and less disk space. Fortunately, you can stop WordPress from doing this by setting the default image sizes to zero in your media settings.

Of course, this is just one of the many ways you can optimize your WordPress site. If you’re looking to enhance the entire digital experience, learn how our best-in-class hosting plans can help you take your online presence (and your customers) to the next level!

Get started.

Build faster, protect your brand, and grow your business with a WordPress platform built to power remarkable online experiences.

Chat with us!