• 1.
    <?php
  • 2.
    					// Compatibility with versions of WordPress prior to 3.4.
  • 3.
    					if ( function_exists( 'get_custom_header' ) ) {
  • 4.
    						// We need to figure out what the minimum width should be for our featured image.
  • 5.
    						// This result would be the suggested width if the theme were to implement flexible widths.
  • 6.
    						$header_image_width = get_theme_support( 'custom-header', 'width' );
  • 7.
    					} else {
  • 8.
    						$header_image_width = HEADER_IMAGE_WIDTH;
  • 9.
    					}
  • 10.
     
  • 11.
    					// Check if this is a post or page, if it has a thumbnail, and if it's a big one
  • 12.
    					if ( is_singular() && current_theme_supports( 'post-thumbnails' ) &&
  • 13.
    							has_post_thumbnail( $post->ID ) &&
  • 14.
    							( /* $src, $width, $height */ $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'post-thumbnail' ) ) &&
  • 15.
    							$image[1] >= $header_image_width ) :
  • 16.
    						// Houston, we have a new header image!
  • 17.
    						echo get_the_post_thumbnail( $post->ID );
  • 18.
    					elseif ( get_header_image() ) :
  • 19.
    						// Compatibility with versions of WordPress prior to 3.4.
  • 20.
    						if ( function_exists( 'get_custom_header' ) ) {
  • 21.
    							$header_image_width  = get_custom_header()->width;
  • 22.
    							$header_image_height = get_custom_header()->height;
  • 23.
    						} else {
  • 24.
    							$header_image_width  = HEADER_IMAGE_WIDTH;
  • 25.
    							$header_image_height = HEADER_IMAGE_HEIGHT;
  • 26.
    						}
  • 27.
    					?>
  • 28.
    						<img src="<?php header_image(); ?>" width="<?php echo $header_image_width; ?>" height="<?php echo $header_image_height; ?>" alt="" />
  • 29.
    					<?php endif; ?>
<?php // Compatibility with versions of WordPress prior to 3.4. if ( function_exists( 'get_custom_header' ) ) { // We need to figure out what the minimum width should be for our featured image. // This result would be the suggested width if the theme were to implement flexible widths. $header_image_width = get_theme_support( 'custom-header', 'width' ); } else { $header_image_width = HEADER_IMAGE_WIDTH; } // Check if this is a post or page, if it has a thumbnail, and if it's a big one if ( is_singular() && current_theme_supports( 'post-thumbnails' ) && has_post_thumbnail( $post->ID ) && ( /* $src, $width, $height */ $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'post-thumbnail' ) ) && $image[1] >= $header_image_width ) : // Houston, we have a new header image! echo get_the_post_thumbnail( $post->ID ); elseif ( get_header_image() ) : // Compatibility with versions of WordPress prior to 3.4. if ( function_exists( 'get_custom_header' ) ) { $header_image_width = get_custom_header()->width; $header_image_height = get_custom_header()->height; } else { $header_image_width = HEADER_IMAGE_WIDTH; $header_image_height = HEADER_IMAGE_HEIGHT; } ?> <img src="<?php header_image(); ?>" width="<?php echo $header_image_width; ?>" height="<?php echo $header_image_height; ?>" alt="" /> <?php endif; ?>

Copy Code to Clipboard Raw

Sign-in or Create a Free Account.

Snippi uses Twitter or Facebook to register and create accounts. Registration will enable you to keep track of your snippets. We never spam your timeline or wall. Ever.

Sign-in with Facebook Sign-in with Twitter