Posted By

zealmurapa on 04/19/11


Tagged

post wordpress thumbnail


Versions (?)

post thumbnail function and display as background if function exists


 / Published in: PHP
 

post thumbnail function and display as background if function exists

  1. // register post thumbnail function
  2. if ( function_exists( 'add_theme_support' ) ) {
  3. add_theme_support( 'post-thumbnails' );
  4. add_image_size( 'company-logo',90, 55 ); //300 pixels wide (and unlimited height)
  5. }
  6.  
  7. // display if function exists
  8. <?php $src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), $size='company-logo', true, '' ); ?>
  9. <?php if( has_post_thumbnail() ) { ?>
  10. <div class="company_thumbnail" style="background: #FFF url(<?php echo $src[0]; ?>) no-repeat center center !important;">
  11. </div>
  12. <?php } ?>

Report this snippet  

You need to login to post a comment.