We can use add_image_size() function to define additional image sizes along with the default sizes: thumbnail, medium, large and full size. Use the image_size_names_choose filter to access the array which contains the default image sizes, and add the additional image sizes to it.

Add this code to your theme’s functions.php file.

if ( function_exists( 'add_image_size' ) ) {
    add_image_size( 'new-size', 500, 300, true ); // Set custom image size
}

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

Filter image_size_names_choose is in the image_size_input_fields() function in wp-admin/includes/media.php and adding additional or custom image sizes to the media uploader is now very easy.

Reference:

You may also be interested in our other articles on nofollow wordpress tag cloud, replace wp login logo with custom logo, align divs horizontally and improve wordpress jpeg image quality.

Leave a Reply