I would like to unset image sizes before uploading images that are not meant to be featured images. Right now I have a clunky workflow where, whenever I upload images, I comment out the custom image sizes use for featured images, then bulk upload non-featured images. Then I uncomment those lines and then upload the featured images. I have a photosite with thousands of photos so making sure I don't have useless image sizes for non-featured images is important.

I would like to know if there is a way to add a checkbox (probably via a plugin that I create) to the upload new media page at Dashboard > Media > Add New, when checked, it will run a simple piece of code before the media is uploaded.

This is the code I would run if he box is checked.

function disable_featured_image_sizes($sizes)
  return $sizes;
add_filter('intermediate_image_sizes_advanced', 'disable_featured_image_sizes');

My problem is I don't know if it's possible to add such a checkbox to the Add New Media page and, if it was possible, how to get this value in my plugin.

1 Answer 1


You get $sizes as array, where size name is a value, not a key

Try this

    //remove sizes with init hook and remove_image_size
    add_action('init', function ($sizes) {
        return $sizes;

    // or just return sizes you need
    add_filter('intermediate_image_sizes', function ($sizes) {
        return ['thumbnail','medium','large'];

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.