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;
}

If you enjoyed this post, make sure to subscribe to WP Mayor’s RSS feed.
No related posts.






Hi, Thx for the tip, but, it doesn’t work on my website.
i pasted your code in my function file and when i want to insert a pic, i can see my new size without dimension, but i can’t select it…
Try saving the post first and then see if you can select it. Or else try uploading one first image through the media gallery. It should work from then onwards. It just needs to be initialised that first time. Let me know if you still have problems after having tried that.
So, if the image was already uploaded, it seems to be KO, but if i upload a new image, it’s OK.
Thx for your help, it will be usefull!
Welcome
Anaother question: Can we use this custom image size in gallerie now?
It should work as if it was a normal default wordpress size, so it should be usable in galleries too. There is also a great plugin called ‘Regenerate thumbnails’ which can be useful in combination with the code above.
Thanks for your answer.
it’s Ok, i did what i wanted!!
Hi.
i have created my new image size 300 x 100 like your example but if i upload an image with the same width and height i’m not able to select New Size but only Full Size.
Any help is appreciated!
This is fantastic, great article.
One thing, is there a way to have these custom image sizes show up in the “edit image” editor as well? So if I go to edit the photo in the uploader, when I go to crop it and apply, it only shows the wordpress defaults.
I tried the code and it generates the image in the upload folder but i don’t see the new option in the media upload screen. I’m using 3.3.1 this would be really useful for my client to able to choose image size based on location rather than dimension ie ‘main post’, ‘recent post’
many thanks
neil
is there a way to add multiple new sizes?