title

How to Add Custom Image Sizes to WordPress Uploader

 

How to Add Custom Image Sizes to WordPress Uploader

20 Oct 2013, Posted by antoine in

WordPress 3.3 is finally out, and features a host of new improvements in the UI, along with other novelties.

A new feature I’m digging is the image_size_names_choose filter, which enables us to add new image sizes to the media upload/insert interface.

Check out the code below and the resulting screen:

if ( function_exists( 'add_image_size' ) ) {
    add_image_size( 'new-size', 300, 100, true ); //(cropped)
}

add_filter('image_size_names_choose', 'my_image_sizes');
function my_image_sizes($sizes) {
        $addsizes = array(
                "new-size" => __( "New Size")
                );
        $newsizes = array_merge($sizes, $addsizes);
        return $newsizes;
}