Return to Snippet

Revision: 57753
at June 8, 2012 09:35 by thescottlee


Initial Code
// Add Feature Image size, hard crop
if ( function_exists( 'add_image_size' ) ) {
     add_image_size( 'feature-image', 570, 285, true );
     add_image_size( 'feature-image-small', 285, 285, true);
     add_image_size( 'feature-image-home', 285, 303, true);
}

// To use the image, if feature image exist
<?php if ( has_post_thumbnail() ) { the_post_thumbnail( 'feature-image' ); } ?>

// Add a class to the image
<?php echo the_post_thumbnail( 'feature-image-large', array('class' => 'feature-image') ); ?>

Initial URL

                                

Initial Description
- Use custom image size within template (including if exist)
- Add a class name to a custom image size

Initial Title
Add custom images sizes to WordPress

Initial Tags
wordpress, images

Initial Language
PHP