Mr.Coder
Mr.Coder

Reputation: 440

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.

Upvotes: 1

Views: 2311

Answers (2)

Mr.Coder
Mr.Coder

Reputation: 440

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

add_filter('intermediate_image_sizes_advanced', '__return_empty_array');

Upvotes: 1

Matthew Yabsley
Matthew Yabsley

Reputation: 9

Wordpress makes different size images for different uses within the blog, for example, when showing a list of posts it might use a thumbnail next to the article title and so on. You can disable those with 0 values in the resize settings.

1: Login To Your WP Dashboard. 2: Go to Settings and then, Media. 3: Here you will find 3 various image sizes: thumbnail, medium, large. 4: Decide which image sizes you won't be using and then set those sizes to 0. Update and save your new settings.

Please don't forget to award the final answer to whoever helps. So others can see the solution.

Upvotes: 0

Related Questions