Placeholder canvas

Remove the generation of copies of uploaded images in WordPress

By default, WordPress generates three sizes for each of the original images 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 the copies would be used up  if all were needed and used for a specific purpose in WordPress, but it happens rarely.

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

In most 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 are 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 you downloaded a single image and created  7 copies of this picture in WordPress. Some of the copies can be almost 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 the post, use the average size (medium). I, therefore, recommend simply uploading a smaller size image.

How do we disable the creation of copies?

By default, WordPress creates 3 copies: miniature (thumbnail), average size (medium), and high resolution (large). In addition to these dimensions, a theme can create additional sizes. For example, install post thumbnails for posts in the sidebar or for other purposes. For this, you need to determine how many copies of the image are created at the beginning. To do this, go to the admin panel and upload a large image. Let it be a picture of 1500×1000 pixels (high resolution is needed to create all possible copies).

Then, connect via FTP and go to the directory where the downloaded image is (usually: / wp-content / uploads /). In this directory, files are sorted by year and by month. Go to the directory where the images are stored last year and last  month, there you should see the file you just downloaded and copy:

As you can see in the picture, my test blog created 5 copies. Where is the default copy, and 2 others – in 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

copies

The recommended size for thumbnails and mediums is crucial because these dimensions are specifically employed to construct the standard Gallery and facilitate the preview of downloaded files within the admin panel. If you decide to eliminate these specified dimensions, the standard Gallery’s functionality may become compromised and not perform as intended. In such a scenario, the loading time for thumbnail-uploaded files within the admin panel would be significantly prolonged, as WordPress would then need to load the full-sized original images, leading to potential performance issues.

  1. Disabling the code

The remaining two copies have created a topic. Usually, the code threads responsible for generating additional dimensions can be 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 can 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 be removed or commented out.

  1. 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 is the ‘image-name’ size name (‘homepage-thumb’ in the example above). Removing the hang on the event after_setup_theme this event is usually enough. 999 means that the priority of the delete function, late, i.e., 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 the 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 following this practice for all my projects and it has made my work very easy. .

FAQs on Generation of Copies in WordPress

Will disabling image copies affect my website’s design?

Disabling unnecessary image copies should not affect your website’s design as long as you’re careful about the sizes you disable. It’s important to maintain essential sizes for responsive design and content layout.

How can I remove existing image copies from my media library?

To remove existing image, you can use the “Media Cleaner” plugin or a similar tool. Be cautious when deleting images, as it can affect your website’s appearance and functionality if not done correctly.

Can I re-enable image copies if needed in the future?

Yes, you can re-enable image by removing the code you added to disable them in your theme’s functions.php file or by adjusting the settings of a plugin you used for this purpose.

Are there any performance benefits to removing image copies?

While removing image copies can help reduce clutter and save storage space, the performance impact on your website is minimal. The primary benefits are a cleaner media library and potentially lower hosting costs.

Want faster WordPress?

WordPress Speed Optimization

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

No Credit Card Required.

Whitelabel Web Hosting Portal Demo

Launching WordPress on AWS takes just one minute with Nestify.

Launching WooCommerce on AWS takes just one minute with Nestify.