add_image_size and add_filter(‘image_size_names_choose’, ‘my_custom_image_sizes’) not working with wordpress 3.5.2

I’m running WordPress 3.5.2. The following is an excerpt from my functions.php file, which correctly allows me to select a thumbnail size when I upload an image.

// Basic setup for thumbnail support.
function themeSetup()
{
    add_theme_support('post-thumbnails');

    add_image_size('tiny', 128, 79);
    add_image_size('small', 256, 158);
    add_image_size('medium', 384, 237);
    add_image_size('large', 512, 316);
}
add_action('after_setup_theme', 'themeSetup');

// Addes custom sizes to Media Library.
function addMySizes($defaultSizes)
{
    $mySizes = array
    (
        'tiny' => 'Tiny',
        'small' => 'Small',
        'medium' => 'Medium',
        'large' => 'Large'
    );  

    return array_merge($defaultSizes, $mySizes);
}  
add_filter('image_size_names_choose', 'addMySizes');

As you’ll notice, we have pretty similar answers. I’m not a PHP expert, but those nested functions give me the willies. I would unnest them and see if that fixes your code. Maybe it’s just a timing issue, i.e. your call to add_filter() is too early.

If this doesn’t fix the problem, then it’s probably something else. Try deactivating all your plugins, etc, standard WordPress debug procedure.

Leave a Comment