OK, I’ve managed to work it out myself.
If anyone’s interested here’s how it works:
In functions.php add this function under the add_theme_support( 'post-thumbnails' ); function:
add_image_size( 'mycustomsize', 260, 190, true );
This registers a new image size to be defined for post thumbnails. The ‘true’ in the function tells wordpress to crop images if necessary to achieve the desired proportions. This means your images will be made to be exactly the dimensions specified, not just width/height limited.
Then just call the custom size in your theme by using the image size string in the function:
<?php the_post_thumbnail('mycustomsize'); ?>
Obviously, you can add more custom sizes and call them when required throughout the theme.
Note: Image cropping is only applied to newly uploaded images; images previously uploaded as post thumbnails will not be cropped after adding the image size function, however they will be resized as normal.
Hope this helps some people
Thank you for this infomation, i added:
add_image_size( 'mycustomsize', 80, 80, true );
to my functions.php and included it in the head area with:
echo '<meta property="text" content="' . the_post_thumbnail('mycustomsize') . '" />';
and it outputted the image at the top of the page.
1. can u tell me how i would output the url of this custom sized thumb?
2. it seemed to resize at 80 x 41 – is there anyway to define it exactly 80 x 80?
(edit – ah see you answered this, existing images will not be cropped)
thanks!
ps i’ve been using:
echo '<meta property="text" content="' . wp_get_attachment_thumb_url( get_post_thumbnail_id( $post->ID ) ) . '" />';
and this works well in getting the url but i wanted to know how i could specify an exact thumbnail size.