Associating images to a post or a page

In the version 2.9 WordPress introduced the capability of associating images to a post or a page. When you create your theme you can turn on this feature by simply adding a call to add_theme_support('post-thumbnails') in your functions.php (this file should be located inside you theme folder).

if ( function_exists( 'add_theme_support') ) {
	add_theme_support( 'post-thumbnails' );
	add_image_size( 'image-normal', 96, 9999, false );
	add_image_size( 'image-small', 32, 9999, false );
}

Believe it or not you are ready to go. Once you add this feature, the next time that you are creating or editing a post in the WordPress admin area, you will be presented with the option to add a Feature Image to your post. This will allow you to upload and associate an image to your post.

To show the image in your page you can simply call the_post_thumbnail($feature). Here is an example:


			

References

Add Theme Support
Add Image Size
The Post Thumbnail

Related articles

Retrieving The Thumbnail Image