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.

I'm adding additional image sizes to my theme:

functions.php

add_image_size( 'my-thumbnails', 122, 122, true );  

I used to get thumbnails URL like this:

wp_get_attachment_url(get_post_thumbnail_id($post->ID)); 

And it works like a charm, but I'm not sure how to display 'my-thumbnails' version of the thumbnail?

This doesn't work:

wp_get_attachment_image_src( get_post_thumbnail_id($post->ID),'my-thumbnails' );  

What's wrong?

share|improve this question
add comment

3 Answers

up vote 2 down vote accepted

You should use one of the following:

// Thumbnail
wp_get_attachment_thumb_file( $GLOBALS['post']->ID );

// Custom
wp_get_attachment_image_src( $attachment_id, $size='thumbnail' );
// Or:
wp_get_attachment_image( $attachment_id, $size = 'thumbnail' );
share|improve this answer
add comment

make your own function in function.php for display your images, then call it and put the size on the parameters of the function.

share|improve this answer
    
Are you sure there is no other way? –  Wordpressor Aug 18 '11 at 23:15
    
well, is the better way, no?, or what do you have in mind? –  eveevans Aug 19 '11 at 0:19
add comment

If you're using the thumbnail as a featured image

the_post_thumbnail( 'my-thumbnails' );
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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