Insane amount of copies of images are being made by HivePress and WooCommerce

When uploading an image, either profile picture or a listing image, wordpress generates a crazy ammount of copies in different sizes. In addition to the original image, 13 (!!!) images are generated in these sizes:
100x100
150x150
238x300
400x300
400x400
600x755
750x500
768x966
800x600
814x1024
1221x1536
1628x2048

By searching the plugin/theme(taskhive) code, I can tell that Woocommerce and Hivepress are adding all these new sizes on top of what wordpress creates on its own. This is, to put it lightly, f*in stupid for a markedplace plugin.

Imagine if each Vendor adds 10 pictures to their listing - just that one listing would have 130 image files, 143 if counting the profile picture.

With ten vendors you have 1430 image files, and that is, if they all just have a single listing.

I need to prevent these additional copies from being made, and instead of generating new sizes, I would suggest that you utilize the sizes already defined in base wordpress - it should keep it way smoother.

Regards
Marius

I’ve manage to remove the useless images with this snippet, if anyone else is needs it:

// Disable wordpress generated images
// disable generated image sizes
function juppi_disable_image_sizes($sizes)
{
    unset($sizes['medium']);       // disable medium size
    unset($sizes['large']);        // disable large size
    unset($sizes['medium_large']); // disable medium-large size
    unset($sizes['1536x1536']);    // disable 2x medium-large size
    unset($sizes['2048x2048']);    // disable 2x large size

    return $sizes;
}
add_action('intermediate_image_sizes_advanced', 'juppi_disable_image_sizes');

// disable scaled image size
add_filter('big_image_size_threshold', '__return_false');

// disable other image sizes
function juppi_disable_other_image_sizes()
{

    remove_image_size('post-thumbnail'); // disable images added via set_post_thumbnail_size() 
    remove_image_size('woocommerce_gallery_thumbnail');   // disable any other added image sizes
    remove_image_size('woocommerce_single');   // disable any other added image sizes
    remove_image_size('woocommerce_thumbnail');   // disable any other added image sizes

}
add_action('init', 'juppi_disable_other_image_sizes');

However, I Must raise another issue. When uploading images, and using the litespeed image optimization to generate webp images, these webp images are left behind when deleting the profile picture / listing picture. This might, in the long run, cause alot of mess. Any suggestion?

4 Likes

Hi,

Thank you for your details and this solution.

Is there any solution that the images should get deleted?

Not found any solution yet

Interesting but I just tested this on my website and they get deleted

Have you experienced any issues using this snippet with the normal use of HivePress?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.