WordPress: add custom image sizes to the list of choices in Insert Media.
<?php
/**
* Custom Image Sizes
* - adds all custom image sizes to the list of choices in Insert Media
*/
add_filter( 'image_size_names_choose', function ( $sizes ) {
global $_wp_additional_image_sizes;
if ( !empty( $_wp_additional_image_sizes ) ) {
foreach ( $_wp_additional_image_sizes as $id => $data ) {
if ( !isset( $sizes[$id] ) )
$sizes[$id] = ucfirst( str_replace( '-', ' ', $id ) );
}
}
return $sizes;
});