Custom Post Thumbnails
Along with the new post_thumbnail feature in WordPress 2.9., came the option to register a new post_thumbnail size.
add_image_size( $name, $width = 0, $height = 0, $crop = FALSE)
The Syntax
- $name:
- The custom image name (eg: index_thumb)
- $width:
- The thumb width in pixels
- $height:
- The thumb height in pixels
- $crop:
- The crop mode used when creating the thumbnail
- false:Soft, proportional (default)
- true: Hard
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

FlipFlop 3.0