Wednesday, November 10, 2010

Custom Post Thumbnails

Along with the new post_thumbnail feature in WordPress 2.9., came the option to register a new post_thumbnail size



register a new post_thumbnail size.


add_image_size( $name, $width = 0, $height = 0, $crop = FALSE)

An Example


functions.php


if ( function_exists( 'add_image_size' ) ) add_theme_support( 'post-thumbnails' );

if ( function_exists( 'add_image_size' ) ) {

add_image_size( 'cat-thumb', 200, 200 );

add_image_size( 'search-thumb', 220, 180, true );

}

Using the New Image Sizes

<?php if ( has_post_thumbnail() ) the_post_thumbnail('cat-thumb'); ?>

add_image_size() is defined in wp-includes/media.php


No comments:

Post a Comment