Stop wordpress from creating multiple thumbnail size images
Here is a head start that is really important and you should take into consideration if you still didn’t setup your blog yet. By default, WordPress duplicates the images that you upload into 4 different sizes (thumbnail, medium, medium-large and large) while uploading, and your theme and/or plugin(s) may create more sizes. This is a major issue when you are considering storage space, but there are solutions to this.
The easiest and fastest ways to stop generating image sizes (no coding experience needed)
- Login To Your WP Dashboard.
- Go to Settings and then, Media.
- Here you will find 3 various image sizes: thumbnail, medium, large. Decide which image sizes you won’t be using and then set those sizes to 0.
- Update and save your new settings.
Once you are done, check your theme, as many WordPress themes have their own set of image sizes that it will generate.
You can do this by using an (FTP) client like FileZilla and scan through the directory marked /wp-content/uploads/ to see if this is the case.
If you don’t know how to use an FTP client, then you can look for the following source code in your functions.php file to see if your theme is kicking out additional pictures that you don’t need.
- Go to your WP Dashboard.
- Navigate to Appearance and then, Editor.
- Find your theme’s function.php file and click on it (find it on the right-hand side).
- Search for the following code: add_image_size and/or set_post_thumbnail_size. If the .PHP file contains that code it will appear there and that means that your theme is generating images. If no image_size source code is shown, then you are lucky.
If you find that your .PHP file has the above mention code, then you need to delete the code and update your files in order to cut those out.
Once done edit the code of your theme file, you should go to Appearance » Editor. Go ahead and edit your functions.php file from here.
You need to delete a few line of code from this file that represents the default image sizes. It may look similar to this code below:
set_post_thumbnail_size( 1200, 9999 );
add_image_size( 'homepage-thumb', 220, 180, true );
In the above code, the two fuctions set_post_thumbnail_size and add_image_size allows your theme to generate additional image sizes. deleting the code prevents the theme to add more images in WordPress. If you are going to implement this, make sure you are adding the code in the child theme, as adding the code in the main theme file might be over ridden by the theme providers once the theme is update. To create a child theme for your website, check this article on How to Create a WordPress Child Theme.
Stop Generating Image Sizes Through Adding a code to functions.php
Simply navigate to Appearance > Editor > function.php and add the below code.
function add_image_insert_override($sizes){
unset( $sizes['thumbnail']);
unset( $sizes['medium']);
unset( $sizes['large']);
return $sizes;
}
add_filter('intermediate_image_sizes_advanced', 'add_image_insert_override' );
Stop Generating Image Sizes Using a plugin
Stop generating image sizes plugin is one of several plugins that can take care of this issue for you.
If you are facing issue with uploading files to your WordPress site, learn How to Increase the WordPress Maximum Upload File Size