Removing Image Sizes for Custom Post Type

May be this filter should work intermediate_image_sizes

Note: This solution will work if you are uploading an image from post edit screen. (tested on localhost with WP-3.8.1)

add_filter( 'intermediate_image_sizes', 'ravs_slider_image_sizes', 999 );
function ravs_slider_image_sizes( $image_sizes ){

    // size for slider
    $slider_image_sizes = array( 'your_image_size_1', 'your_image_size_2' ); 

    // for ex: $slider_image_sizes = array( 'thumbnail', 'medium' );

    // instead of unset sizes, return your custom size for slider image
    if( isset($_REQUEST['post_id']) && 'your_custom_post_type' === get_post_type( $_REQUEST['post_id'] ) )
        return $slider_image_sizes;

    return $image_sizes;
}

Leave a Comment