Drew a blank Googling for this...

Our website homepage shows a grid of featured image thumbnails on the home page. Some of these images are portrait and some are landscape.

I would like to be able to

  1. add a custom image size for portrait image thumbs
  2. add a custom image size for landscape image thumbs
  3. be able to select the size that will be used from between the above two sizes, within the post editor, when choosing the featured image for the post

The overall aim is to have a grid where the portrait images are the same height as 2 x landscape images (stacked) + 2 x padding so that the grid is always flush

Many thanks for any help with this

1 Answer 1


// First, enable thumbnails if they are not enabled yet
add_theme_support( 'post-thumbnails' );

 * Add image dimensions
 * name
 * width
 * height
 * crop or resize (true or false)
 * 99999 means very big number
add_image_size( 'featured-portrait'  , 200  , 99999, false );
add_image_size( 'featured-landscape' , 99999, 200  , false );

// Next, choose names for these dimension sets
add_filter( 'image_size_names_choose', 'my_custom_sizes' );

function my_custom_sizes( $sizes ) {
    return array_merge( $sizes, array(
        'featured-portrait'  => __('Portrait, 200px wide'),
        'featured-landscape' => __('Landscape, 200px high'),
    ) );

You can vary width, height and crop to fit your needs.

See add_image_size() for more.

  • Thanks, I tried this and, although it made the two custom sizes successfully, there was nothing to allow me to choose between the two sizes when selecting the featured image Commented Jul 3, 2018 at 11:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.