Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.