I'm confused, because there are a lots of functions about attachments . I've tried a lots of functions. I'm setting a featured image for my every blog post.
I have to get different sizes of this image. FOr example a need this variations of featured image
600px*400px
300px*150px
64px*64px
(Images can be cropped).
I'm adding these new image sizes (in functions.php
):
add_image_size('custombig', 600, 400, TRUE);
add_image_size('customsmall', 300, 152, TRUE);
add_image_size('customimage', 64, 64, TRUE);
(in single.php
)
<?php
// inside a Loop
if (has_post_thumbnail( $post->ID ))
$image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'customsmall' );
?>
<img alt="" src="<?php echo $image[0]; ?>" />
But it's printing full size of image. Not cropping or resizing it.
Can you teach me getting different sizes of attached images, or suggest me a few articles about this ?