If I use:

add_image_size('main_image', 750, 375, true);

to add additional thumbnail size. Then how can i get that size if i have only key main_image.

  • 2
    Are you trying to get the names of the custom image sizes, or are you trying to return/output the actual image with the custom size? Mar 13, 2013 at 18:25

3 Answers 3


This is answered here: Get post thumbnail size

global $_wp_additional_image_sizes;
// Output width
echo $_wp_additional_image_sizes['main_image']['width'];
// Output height
echo $_wp_additional_image_sizes['main_image']['height'];

To use the new image size in a theme you need to call to it with

<?php if ( has_post_thumbnail() ) { the_post_thumbnail( 'main_image' ); } ?>

If you need additional sizes just add more.

add_image_size('main_image', 750, 375, true);

add_image_size('main_image_2', 650, 275, true);

add_image_size('main_image_3', 550, 175, true);

You can learn how this function works here http://codex.wordpress.org/Function_Reference/add_image_size


Use the_post_thumbnail() to output the featured image at the specified size:

<?php the_post_thumbnail( 'main_image' ); ?>

Use get_the_post_thumbnail() to return the HTML image markup for the image at the specified size:

<?php get_the_post_thumbnail( get_the_ID(), 'main_image' ); ?>

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