0

As for an ad management plugin, I'm using WordPress' default media uploader. And WP Media Uploader automatically resizes images. But as the ad image is already resized (i.e.: 225 x 100px) it need not to resize into a new file for thumbnail (100 x 100px); because, that thumbnail is unnecessary for the site.

The cause I presented here, may be a very minute for such a solution, but in case, there is any other massive issue that, in such plugin we can stop the auto resizing with WP Media Uploader only on that plugin-uploads - I think that can be a good solution for any site.

Is there a way to use WP Media Uploader, but can stop auto resizing images only onto that particular case uploads?

But I also know that, plugin like Regenerate Thumbnails can override the rules and can do what I prohibited in my plugins for the site's space-savvy consumption.

3
  • To get you correctly, you do not want any thumbnails generated to save space? because otherwise you could just output the full size, and get the image you uploaded.
    – fischi
    Jan 30, 2014 at 16:23
  • @fischi: You got the intention right. But as for implementation, not just thumbnails, it can be for any additional image sizes other than the original. I want to upload the full size and get the full size to be echoed, and only the full size to be stored (no other resizes) only on particular case - not global to a WP site. Jan 30, 2014 at 16:44
  • Hm, if you use the default uploader I do not think that it is possible. But - why don't you just use a regular uploader, not one connected to the Media Library?
    – fischi
    Jan 30, 2014 at 17:12

1 Answer 1

2

Use the Filter Hook intermediate_image_sizes_advanced for control the resize function for different sizes. This hook get a array of different sizes and can control your resize with your requirements. Add your logic inside a plugin and remove sizes via this hook.

 // the hook in core
 $sizes = apply_filters( 'intermediate_image_sizes_advanced', $sizes );

A small example to remove the resize for mediumsize.

add_filter( 'intermediate_image_sizes_advanced', 'fb_filter_image_sizes');
function fb_filter_image_sizes( $sizes) {

    unset( $sizes['thumbnail']);

    return $sizes;
}
3
  • Thanks @bueltge. Please ensure me that, it won't effect the global WP 'medium' size, but only the 'medium' size in my plugin's Media Uploader... Jan 31, 2014 at 4:02
  • 1
    Yes, I have understand, that you create a rule, that it only works on your plugin. Bur here in the question it is not readable, how we can identifier the plugin. Is your plugin a new page inside the backend of WP, than can you identifier with the function get_current_screen() and the hook from my answer run only on the right value inside the array of the return of this function. To understand get_current_screen() use the plugin Debug Objects and see his result on your page.
    – bueltge
    Jan 31, 2014 at 13:45
  • I've added the link of my plugin on github with the question. It has two screens - one to add the ad, and other to list the already added ad[s]. So you are suggesting we can use the filter using the specific get_current_screen()? If that works, I'll try later, it'd be good. Thanks. Jan 31, 2014 at 13:50

Your Answer

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

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