Monday, November 11, 2013

Custom image sizes missing in the media up-loader in Wordpress administration

Does your Wordpress media uploader in the administration miss the custom images sizes that you have configured? Don't worry.

In Wordpress 3.5 something seemed to have changed and any custom image sizes weren't available to select when inserting an image to a post or page. I really don't know what have changed but I know the solution and it's quite simple.

The thing you need to do is to create an filter in your functions.php that modify the Wordpress built-in function "image_size_names_choose()" and add all your custom image size to the "list".

Add this following code to your functions.php-file:

function my_custom_sizes( $sizes ) {    return array_merge( $sizes, array(        'custom-300' => __('Custom 300')    ) );}add_filter( 'image_size_names_choose', 'my_custom_sizes' );
That's it!

And if your don't remember how to add a custom image size in Wordpress. It's simple. Add this code to your functions.php-file:

add_image_size( 'custom-300', 300, 300 );

No comments:

Post a Comment