18 April, 2013 — Snippets, WordPress

Add Custom Image Sizes to WordPress Uploader

A few days ago I needed to add a custom image size to the WordPress uploader and I wasn’t sure how I would go about doing this. Then I found a new hook that was added in WordPress 3.3…

It means more image size options for your websites, with all the magical ease of WordPress’ image management and cropping – upload once and job done!

All the following code goes into your themes functions.php file.

Show me the code!

Firstly we need to add your custom image sizes so WordPress knows about it.

add_image_size('featured', 670, 280, true);

Find out more about add_image_size here.

Once you have this added we can now add a bit more code that will actually add the size to the drop down menu. You can do this by using the image_size_names_choose filter like so:

function my_image_sizes($sizes){
$addsizes = array(
"featured" => __("Featured")
$newsizes = array_merge($sizes, $addsizes);
return $newsizes;
add_filter('image_size_names_choose', 'my_image_sizes');

Note the first part of the array is the name you gave in the first function and the second part is what the end-user will see in the drop down menu.

Once you have all this code added save and upload your functions.php file and your good to go! If you have any problems comment below and I will help you out as best I can.