Created
May 12, 2012 20:00
-
-
Save wycks/2668630 to your computer and use it in GitHub Desktop.
Testing image size filter for post editor
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 | |
// test images | |
add_image_size( 'ducks', 350, 350, true ); | |
add_image_size( 'cows', 750, 150, true ); | |
//this function does not work and acts very wacky | |
function add_image_check(){ | |
global $_wp_additional_image_sizes; | |
//default array | |
$default = array( | |
'thumbnail' => __('Thumbnail'), | |
'medium' => __('Medium'), | |
'large' => __('Large'), | |
'full' => __('Full Size') | |
); | |
//array from add_image_size | |
$new = $_wp_additional_image_sizes; | |
//merge the arrays | |
$result = array_merge($default, array_keys($new)); | |
return $result; | |
}; | |
add_filter('image_size_names_choose', 'add_image_check' ); | |
//######################################################### | |
//this function works | |
function add_image_check_part2(){ | |
global $_wp_additional_image_sizes; | |
//default array with hardcoded values fro add_image_size | |
$default = array( | |
'thumbnail' => __('Thumbnail'), | |
'medium' => __('Medium'), | |
'large' => __('Large'), | |
'full' => __('Full Size'), | |
'ducks' => __('Ducks'), | |
'cows' => __('Cows') | |
); | |
return $default | |
}; | |
add_filter('image_size_names_choose', 'add_image_check_part2' ); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment