How to Stop WordPress From Resizing the Uploaded Photos

How to Stop WordPress From Resizing the Uploaded Photos
How to Stop WordPress From Resizing the Uploaded Photos

Find out How to Stop WordPress From Resizing the Uploaded Photos as we have published it via African2nice about How to Stop WordPress From Resizing the Uploaded Photos – Online Fintech Tips for How to Stop WordPress From Resizing the Uploaded Photos.

Images 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.

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.

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.

Read Also: Best Office Productivity Suites for Professionals

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 optionSimply 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.

Be the first to comment

Leave a Reply