Skip to content

Instantly share code, notes, and snippets.

@donnamcmaster
Created April 7, 2017 20:50
Show Gist options
  • Save donnamcmaster/0b7053021959a7fc98ce5b28f518e9ed to your computer and use it in GitHub Desktop.
Save donnamcmaster/0b7053021959a7fc98ce5b28f518e9ed to your computer and use it in GitHub Desktop.
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