Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

The last update broke my workflow, as the method of using custom image size inside the media manager has definitely changed.

i'm trying to add my previously registered image sizes to the new dropdown.

share|improve this question
    
Add your code to your question please. –  toscho Dec 15 '12 at 15:10

3 Answers 3

This was helpful for me:

function setup_image_sizes() {

    if ( function_exists( 'add_image_size' ) ) {

        add_image_size( 'image-retina', 576, 320, true );
    }

    function pc_image_sizes($sizes){

        $sizes['image-retina'] = __('Image');
        return $sizes;
    }

    add_filter('image_size_names_choose', 'pc_image_sizes');
}

add_action( 'after_setup_theme', 'setup_image_sizes' );
share|improve this answer
    
Please explain why that could solve the problem. –  toscho Jan 20 '13 at 16:56
    
I had the same problem, I spent several days looking for a solution. Tried dozens of solutions, and only this has helped me. –  Stanislau Ladutska Apr 4 '13 at 10:28

Assuming you added a custom image size in after_setup_theme and it has an id such as below ...

... add_image_size( 'other-thumb', 240, 200, true ); 

You can add a filter which will add the size to the list of sizes in the new media manager. Just make sure to pass in the id/slug and then title you want in the dropdown and wallah!

// Add other image size options to insert image dialog
add_filter('image_size_names_choose', 'xf_more_sizes', 4, 1);
function xf_more_sizes($sizes){
   $sizes['other-thumb'] = __('Othernail');
   return $sizes;
}
share|improve this answer

You will need to paste your code in order for us to review where the issue is, however, I can demonstrate how I accomplish this in Wordpress v3.5

Please observe the comments in my_insert_custom_image_sizes:

function my_insert_custom_image_sizes( $sizes ) {
    // get the custom image sizes
    global $_wp_additional_image_sizes;
    // if there are none, just return the built-in sizes
    if ( empty( $_wp_additional_image_sizes ) )
        return $sizes;

    // add all the custom sizes to the built-in sizes
    foreach ( $_wp_additional_image_sizes as $id => $data ) {
        // take the size ID (e.g., 'my-name'), replace hyphens with spaces,
        // and capitalise the first letter of each word
        if ( !isset($sizes[$id]) )
            $sizes[$id] = ucfirst( str_replace( '-', ' ', $id ) );
    }

    return $sizes;
}


function custom_image_setup () {
    add_theme_support( 'post-thumbnails' );
    add_image_size( 'custom-image-size-1', 160, 9999 ); //  small columned
    add_image_size( 'custom-image-size-2', 300, 9999 ); //  medium
    add_image_size( 'custom-image-size-3', 578, 190, true ); //  cropped
    add_filter( 'image_size_names_choose', 'my_insert_custom_image_sizes' );
}

add_action( 'after_setup_theme', 'custom_image_setup' );

Note that I am adding the my_insert_custom_image_sizes filter in the after_setup_theme which is a good practice.

share|improve this answer
    
Did this answer help you? If so, please upvote/accept as correct. –  Christine Cooper Dec 20 '12 at 14:42

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.