Return to Snippet

Revision: 44840
at April 19, 2011 21:41 by zealmurapa


Initial Code
// register post thumbnail function
if ( function_exists( 'add_theme_support' ) ) { 
  add_theme_support( 'post-thumbnails' ); 
  add_image_size( 'company-logo',90, 55 ); //300 pixels wide (and unlimited height)
}

// display if function exists
<?php $src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), $size='company-logo', true, '' ); ?>
<?php if( has_post_thumbnail() ) { ?>
<div class="company_thumbnail" style="background: #FFF url(<?php echo $src[0]; ?>) no-repeat center center !important;">
</div> 
<?php } ?>

Initial URL


Initial Description
post thumbnail function and display as background if function exists

Initial Title
post thumbnail function and display as background if function exists

Initial Tags
post, wordpress

Initial Language
PHP