Skip to content

Instantly share code, notes, and snippets.

@media317
Last active December 17, 2015 11:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save media317/5603201 to your computer and use it in GitHub Desktop.
Save media317/5603201 to your computer and use it in GitHub Desktop.
Add Image Sizes to Media Selection
//** Add image sizes to Media Selection */
add_filter('image_size_names_choose', 'me_display_image_size_names_muploader', 11, 1);
function me_display_image_size_names_muploader( $sizes ) {
$new_sizes = array();
$added_sizes = get_intermediate_image_sizes();
// $added_sizes is an indexed array, therefore need to convert it
// to associative array, using $value for $key and $value
foreach( $added_sizes as $key => $value) {
$new_sizes[$value] = $value;
}
// This preserves the labels in $sizes, and merges the two arrays
$new_sizes = array_merge( $new_sizes, $sizes );
return $new_sizes;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment