Skip to content

Instantly share code, notes, and snippets.

@wycks
Created May 12, 2012 20:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wycks/2668630 to your computer and use it in GitHub Desktop.
Save wycks/2668630 to your computer and use it in GitHub Desktop.
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