0

The images in my WooCommerce product gallery do not need to be resized I only need the original image to display. Is there a way to add a toggle button to wordpress media to tell it to generate other sizes or not?

I did not find a plugin or code for this... Of course, there is a plugin that does almost the same thing, but the way to do it to achieve the desired result is very long.

6
  • Can I ask why you think you don't need this? What problem are you solving? Depending on the original size of your images this could cause a significant performance issue. Jan 18 at 9:38
  • @JacobPeattie When a size is not used, why should it be made? That eats up our storage space?
    – Monoor
    Jan 19 at 8:57
  • WordPress can't know how are going to be used, so you could easily end up missing image sizes when you need them. Also, I'm certain that the WooCommerce gallery uses resized versions of the image. Lastly, storage is cheap these days. A thumbnail version of an image is using negligible storage. Jan 19 at 9:01
  • @JacobPeattie There is a proverb in our culture: It collects drop by drop and then becomes the sea, And yes wp can't know, That's why I created this question
    – Monoor
    Jan 19 at 10:42
  • Haven't tried this myself but according to WPEngine this is how: wpengine.com/resources/prevent-wordpress-image-size-generation/…. Jan 24 at 16:28

1 Answer 1

2

That's a bit tricky because WordPress doesn’t offer this functionality out of the box. But a workaround would be to stop WordPress from generating additional image sizes for uploaded images. But it will apply to all image uploads, not just those in the WooCommerce product gallery. If you wanted to try it out, here's the code for that:

function disable_image_sizes($sizes) {
    unset($sizes['thumbnail']);
    unset($sizes['medium']);
    unset($sizes['large']);
    unset($sizes['medium_large']);
    unset($sizes['1536x1536']);
    unset($sizes['2048x2048']);
    // Add any additional sizes you want to remove
    return $sizes;
}
add_filter('intermediate_image_sizes_advanced', 'disable_image_sizes');
1
  • Thank you, but the problem is obvious! Please dont answer in vain...
    – Monoor
    Jan 19 at 11:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.