Last active
December 14, 2015 23:09
-
-
Save jesgs/5163738 to your computer and use it in GitHub Desktop.
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 | |
/** | |
* Add image sizes to Insert Into Post list | |
* @see http://goo.gl/CJdR4 | |
* | |
* @param array $sizes | |
* @return array | |
*/ | |
add_filter('image_size_names_choose', 'display_image_size_names', 11, 1); | |
function display_image_size_names($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] = ucwords(str_replace('-', ' ', $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