Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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
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? –  Chip Bennett Mar 13 '13 at 18:25
add comment

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.

3 Answers

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
add comment

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
add comment

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
add comment

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