WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This question already has an answer here:

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.

share|improve this question

marked as duplicate by toscho Mar 13 '13 at 18:37

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

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? – Chip Bennett Mar 13 '13 at 18:25
up vote 2 down vote accepted

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'];
share|improve this answer

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' ); ?>
share|improve this answer

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

share|improve this answer

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