Remove the generation of copies of uploaded images in WordPress

Table of Contents

By default, WordPress generates 3 sizes for each of the original image that we load. Themes and plugins can create additional image sizes. Thus, your website can generate 5 to 10 copies of each uploaded image. This may increase the amount of required space on the disk and the size of the backup files. And all would do if all the copies would be needed and used in the subject, but it happens rarely.

When you need to remove the generation of copies of pictures?

In most of cases, you do not need images in different sizes. If you do not use expensive hosting and disk space is limited, it is worth checking out. It does not create any copies that not used in the subject. Also, multiple copies of the downloaded images are placed in the uploads folder, which can significantly increase the size of backup files – it is at least not convenient. Imagine yourself, you downloaded a single image and created yet WordPress 7 copies of this picture, some of the copies can be almost of the same size as the original. If you have thousands of images on the site, then one day it may become a problem.

Note: To display images in the media loader while adding pictures to post, used the average size (medium). I, therefore, recommend to simply upload a smaller size images.

How to disable the creation of copies?

By default, WordPress creates 3 copies: miniature (thumbnail), average size (medium), high resolution (large). In addition to these dimensions, a theme can create additional sizes. For example, to install post thumbnails for posts in the sidebar, or for other purposes. First of all, you need to determine how many copies of the image is created at startup. To do this, go to the admin panel and upload a large image, let it be a picture 1500×1000 pixels (high resolution is needed to create all possible copy). Then, connect via FTP and go to the directory where the downloaded image (usually: / wp-content / uploads /). In this directory, files are sorted by year and by month, go to the last year and a month, there you should see the file you just downloaded and copy:

Copies of the original downloaded pictures

As you can see in the picture, my test blog created 5 copies. 3 Where is the default copy, and 2 others – is setting the theme. To disable the generation of copies of the default image, go to Settings> Media and put zero only for the large size.

(/ Wp-content / uploads / 2015/11 / mediasettings.png) Page settings Media

media-settings

The size of a thumbnail and medium is recommend leaving because this size used to create the standard gallery and preview the downloaded files in the admin panel. If you remove this size, the standard Gallery will not work as expected. A thumbnails uploaded files in the admin panel will be loaded for a long time because WP will have to load the originals.

Disabling the code

The remaining two copies have created a topic. Usually, the code threads responsible for generating additional dimensions can get found in the file functions.php. Look for the dimensions that you have seen going through FTP (672, 1038, 576) and the function add_image_size (). It will look something like this:

add_image_size (‘homepage-thumb’, 1038, 576, true);

Remove or comment out this line, so you disable the generation of size 1038×576.

Also, for the creation of copies can meet function set_post_thumbnail_size (), it looks like this:

set_post_thumbnail_size (150, 150);

It will also need to remove or comment out.

Disabling the filter

In the version of WordPress, there is a special feature that allows you to remove the thumbnail size: remove_image_size () . Now, instead of deleting rows, you can disable unnecessary size by adding a filter to the file functions.php:

function remove_plugin_image_sizes() {
	remove_image_size('image-name');
}
add_action('after_setup_theme', 'remove_plugin_image_sizes', 999);

Here ‘image-name’ size name (‘homepage-thumb’ in the example above). Removing hung on the event after_setup_theme, this event is usually enough. 999 means that the priority of the delete function, late, ie function will be called after the other during this event.

Conclusion

Before using material from this article, make sure that deleted sizes are not used in the current theme, as thumbnails for entries in the sidebar or in other types of posts. Remove copies created only when they are not necessary for the proper operation of the theme.

Pay attention to plugin for creating thumbnails: Kama Thumbnail. It can be used to dynamically create those sizes needed in the subject. And only load originals. I’m doing on all the projects.

Plug-in

If you make changes to the working website already loaded with pictures, you can use the plugin “Force Regenerate Thumbnails”, to delete all copies and leave only the originals and make copies again, based on the new settings.

Note:

If you are looking for Managed WordPress Hosting that is isolated from other users on the server, We provide you with everything for which you have been waiting for. Our hosting is built on a blazing-fast SSD latest hardware That’s Highly tuned for optimum performance. The hosting includes daily backups, anytime money back, 99.97% uptime and 24×7 support.

Fully Managed WordPress Hosting

Nestify’s AWS powered dedicated CPU servers keep your sites fast, secure, and always up to date.

Want faster WordPress?

WordPress Speed Optimization

Try our AWS powered WordPress hosting for free and see the difference for yourself.

No Credit Card Required.