Skip to content

@wycks /gist:2668630
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Testing image size filter for post editor
<?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
Something went wrong with that request. Please try again.