How to Stop WordPress From Resizing the Uploaded Photos

On
Blue Host Creative Polaroid photos on a wooden tableImages are one of the prominent content forms consumed widely on the internet. Correctly using images on a website is a vast subject and requires great attention to please both the visitors and the search engines. No matter which CMS you're using to power your website—sooner or later—you're bound to face few image-related issues (big or small) which may affect your content creation routine. One such issue is related to self-hosted WordPress blogs. It's the creation of multiple images of different sizes created from the originally uploaded image. Sometimes, bloggers just want to use the original one instead of serving the resized version to the visitors. The following tutorial will help you in disabling the default multiple image-creation behavior of WordPress. If you're using very large images for your blog posts, I'll recommend sticking with the default setup. I'll also advise you to take a backup of your blog before applying the steps mentioned below. Let's get started to reclaim our originally uploaded images.

Polaroid photos on a wooden table
If you're technically challenged and are reluctant to apply the methodologies mentioned below, take help of an expert for the same. Try applying these changes at the weekends.

Read Also:
How to Enhance and Improve Your Blog Photos with Simple Tricks


I personally make sure that I've disabled this feature on every new website designed for my clients. I encourage them to use a separate resized and optimized version of an image—wherever required.

Reasons to Disable Multiple Image Sizes

Before we start, let's once quickly go through the reasons for which one may decide to disable this feature. If you're running your website on a slow and limited-space shared server, the reasons mentioned below are totally justified.
  • Saves disk space - If you have limited disk space on your hosting plan, disabling this feature is highly recommended. It'll stop generating additional images saving your disk space by many folds.
  • Shrinks site backups - If your media library is huge with multiple image sizes, website's backup archive will be huge as well. Creating such an archive will also put a burden on the web server. Once disabled, you'll see a significant reduction in the size of the backup file.
  • Reduces clutter and bloat - Quite obviously, reduction in the media library size will effectively reduce the bloat or unnecessary content on the website.
Website owners with extremely huge image archive will find these reasons good enough to go ahead with it. Let's move on and learn some of the basics related to this subject.

WordPress Multiple Image Size Creation Basics

By default, for each of the uploaded image, WordPress generates several copies of the same of varying sizes. These different size copies of the original image may or may not be used within your website layout. Following are the default image sizes created by WordPress.
  • Thumbnail: It's a square (proportional) 150 x 150 px image often used in sections like related posts. Name: thumbnail
  • Medium: It's a medium-sized copy 300 x 300 px of the uploaded image often used in post excerpts by certain themes. Name: medium
  • Medium Large: It's a larger copy 768 x 0 px of the medium category image where the height is proportionally adjusted. Name: medium_large
  • Large: As the name suggests, this is the larger version 1024 x 1024 px of the uploaded image one can use within landing pages and similar type of content sections. Name: large
  • Full: And, this is the original image uploaded by the user. Generally, a user almost always wants to use it within a blog post. Name: full
Apart from these standard and default sizes, a theme or a plugin may generate additional image sizes.

Disable Default Image Sizes (The Easy Way)

Let's start with the easiest part! First of all, we'll disable the default WordPress image sizes from within the dashboard GUI. Here's how to do it.

Within your WordPress dashboard, go to the Settings → Media → Media Settings → Image sizes option. Here you'll find all the default WordPress image sizes.

WordPress image sizes option
Simply change all the image sizes to zero as shown in the image above. It'll stop the generation of additional (default) image sizes for all the images you'll upload in the future.

Make sure to click the save button after making the changes. Remember, this action won't delete the old image copies residing on your web server. In case, you're using one of the default image sizes on your website, leave its original values—intact.

Disable Default and Custom Image Sizes (Through Code Edits)

Another way to disable both the default image sizes and the custom image sizes is through the change of the relevant code. If you're not comfortable with it, I'll recommend a plugin for the same.

And, if you're comfortable with making small code changes, follow this process. The theme file that needs our attention is functions.php accessible through the Appearance → Editor option.

Within the functions.php file, look for all the instances of the following two functions.


add_image_size( 'image-size-name', width, height, true [optional parameter] );

set_post_thumbnail_size( width, height );

Delete all the occurrences of both these functions and update the file. Another way to disable all the image sizes except the original uploaded photo is to add the following snippet within your theme's functions.php file.


function remove_all_image_sizes() {
    foreach ( get_intermediate_image_sizes() as $size ) {
            remove_image_size( $size );
    }
}
 
add_action('init', 'remove_all_image_sizes');

Example: And, let's suppose that apart from the original uploaded image, you also want to keep two image sizes. The medium_large image and a custom-sized portfolio-avatar image. Except these 3 image sizes, you want to disable all the other image sizes.

Here's the snippet to make that happen.


function remove_select_image_sizes() {
    foreach ( get_intermediate_image_sizes() as $size ) {
        if ( !in_array( $size, array( 'medium_large', 'portfolio-avatar' ) ) ) {
            remove_image_size( $size );
        }
    }
}
 
add_action('init', 'remove_select_image_sizes');

After disabling the image sizes, use this powerful plugin to remove all the old unused images and to generate the new images sizes—if any. If your image archive is huge, this process may take some time.

Caution: If you're not sure which image sizes should be disabled, do not go ahead with this process, because it may break your existing design and layout.


I'll recommend trying it first on a local copy of your website. Once you're sure everything is working as expected, apply it on your live website. You'll recover a lot of disk space after disabling the image sizes.