Created
April 7, 2017 20:50
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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