Not entirely sure when this appeared in WordPress, I remember searching through the source code a while back to find a way to do this and it wasn’t available then.
Anyway, WordPress now has a image_size_names_choose filter that allow you to show your custom image sizes in the Add Media popup.
It is very handy if you’re building a website which requires additional sizes.
Here’s how it’s done (put that in your functions.php file or somewhere in your plugin)
add_action( 'after_setup_theme', 'my_setup_theme' );
function my_setup_theme() {
// Create some new image sizes
add_image_size( 'feature', 250, 250, true );
add_image_size( 'portfolio', 450, 150, false );
}
add_filter('image_size_names_choose','my_image_size_names',10,1);
function my_image_size_names($sizes)
{
// Give them a name, and presto!
$sizes['feature']= 'Feature Image';
$sizes['portfolio']= 'Portfolio Image';
// Don't forget to return the array of sizes.
return $sizes;
}
Click on your Add Media icon above the editor and you should see the custom sizes for each uploaded image.