WordPress 3.5 – Add custom image size

You can pest following code in function.php.

add_theme_support('post-thumbnails');
add_image_size( $name, $width, $height, $crop);
add_image_size('Home Top', 120, 120, true);
add_image_size('Home bottom', 270, 90, false);
add_image_size('Archive thumb', 150, 75, true);
add_image_size('Special', 397, 224, true);
add_image_size( 'Test cropped', 500, 500, true );

function sgr_display_image_size_names_muploader( $sizes ) {

    $new_sizes = array();

    $added_sizes = get_intermediate_image_sizes();

    foreach( $added_sizes as $key => $value) {
        $new_sizes[$value] = $value;
    }

    // This preserves the labels in $sizes, and merges the two arrays
    $new_sizes = array_merge( $new_sizes, $sizes );

    return $new_sizes;
}
add_filter('image_size_names_choose', 'sgr_display_image_size_names_muploader', 11, 1);

This code worked for me in wordpress3.5.

Regards
Onkar Kubal

Leave a Comment

tech