'remove image sizes from media uploader box
I have used custom image sizes in wordpress with "add_image_size" and it's working fine.
I tried to remove default image sized with following code:
function filter_image_sizes( $sizes) {
unset( $sizes['thumbnail']);
unset( $sizes['medium']);
unset( $sizes['large']);
return $sizes;
}
add_filter('intermediate_image_sizes_advanced', 'filter_image_sizes');
But these default images sizes are still visible in media upload popup.

Solution 1:[1]
Tested on 3.5.1 in my localhost
Using unset and intermediate_image_sizes_advanced will work but only on images uploaded after the function is added. To change it for existing images you need to regenerate them using a plugin ( in essence deleting that image size) or just hide that option from being visible.
// add custom image size
function mytheme_95344() {
add_image_size('x-la',800,800, false);
}
add_action( 'after_setup_theme', 'mytheme_95344' );
// remove it
function remove_image_size_95344($sizes) {
unset($sizes['x-la']);
return $sizes;
}
add_filter('intermediate_image_sizes_advanced', 'remove_image_size_95344');
So this x-la size will still show for images before the unset function was added.
To remove this you can try.
Hide it from the display using image_size_names_choose
function remove_image_size_95344($possible_sizes) {
unset( $possible_sizes['x-la'] );
return $possible_sizes;
}
add_filter('image_size_names_choose', 'remove_image_size_95344');
Answer from https://wordpress.stackexchange.com/questions/95344/hide-custom-image-sizes-from-media-library#answer-95350
Solution 2:[2]
I tried intermediate_image_sizes_advanced and it wasn't working, so I inspected the get_intermediate_image_sizes() function and saw that they now use the intermediate_image_sizes filter hook.
So I was able to remove all image sizes by doing this.
add_filter('intermediate_image_sizes', function($size){
return [];
},9999);
Fill free to create the callback function separately so it can be unhooked.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Community |
| Solution 2 | Henry Obiaraije |

