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?
3 s
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="my-thumbnails" );
// Or:
wp_get_attachment_image( $attachment_id, $size="my-thumbnails" );