Search code examples
phpwordpressfile-upload

Selectively prevent Wordpress from generating additional image sizes on upload


I am getting some images from clients via a front-end form and uploading those images to the Media Gallery programmatically. The code works fine and uploads the images as intended.

But in the wp-uploads folder it creates copies of these images for all the sizes. I do not want WP to do that only when images are uploaded via this form because just the original image file that the client uploads is sufficient for my need. Could someone please guide me in the right direction? Thank you.


Solution

  • Thanks to a community member, Moshe Gross, the filter to target is

    add_filter('intermediate_image_sizes_advanced', '__return_empty_array');