Advertisement
alchymyth

header image section replacement

Aug 24th, 2012
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.71 KB | None | 0 0
  1. replace this section of header.php in 'blue splatter':
  2.  
  3. <div id="headbg-title" style="background: url(<?php header_image(); ?>); width:<?php echo HEADER_IMAGE_WIDTH; ?>px; height:<?php echo HEADER_IMAGE_HEIGHT; ?>px;">
  4.                     <hgroup>
  5.                 <h1 id="site-title"><span><a href="<?php echo esc_url( home_url( '/' ) ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></span></h1>
  6.                 <h2 id="site-description"><?php bloginfo( 'description' ); ?></h2>
  7.                     </hgroup>
  8.                 </div>
  9.  
  10. with this section from the default header.php of Twenty Eleven:
  11.  
  12.             <hgroup>
  13.                 <h1 id="site-title"><span><a href="<?php echo esc_url( home_url( '/' ) ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></span></h1>
  14.                 <h2 id="site-description"><?php bloginfo( 'description' ); ?></h2>
  15.             </hgroup>
  16.  
  17.             <?php
  18.                 // Check to see if the header image has been removed
  19.                 $header_image = get_header_image();
  20.                 if ( $header_image ) :
  21.                     // Compatibility with versions of WordPress prior to 3.4.
  22.                     if ( function_exists( 'get_custom_header' ) ) {
  23.                         // We need to figure out what the minimum width should be for our featured image.
  24.                         // This result would be the suggested width if the theme were to implement flexible widths.
  25.                         $header_image_width = get_theme_support( 'custom-header', 'width' );
  26.                     } else {
  27.                         $header_image_width = HEADER_IMAGE_WIDTH;
  28.                     }
  29.                     ?>
  30.             <a href="<?php echo esc_url( home_url( '/' ) ); ?>">
  31.                 <?php
  32.                     // The header image
  33.                     // Check if this is a post or page, if it has a thumbnail, and if it's a big one
  34.                     if ( is_singular() && has_post_thumbnail( $post->ID ) &&
  35.                             ( /* $src, $width, $height */ $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), array( $header_image_width, $header_image_width ) ) ) &&
  36.                             $image[1] >= $header_image_width ) :
  37.                         // Houston, we have a new header image!
  38.                         echo get_the_post_thumbnail( $post->ID, 'post-thumbnail' );
  39.                     else :
  40.                         // Compatibility with versions of WordPress prior to 3.4.
  41.                         if ( function_exists( 'get_custom_header' ) ) {
  42.                             $header_image_width  = get_custom_header()->width;
  43.                             $header_image_height = get_custom_header()->height;
  44.                         } else {
  45.                             $header_image_width  = HEADER_IMAGE_WIDTH;
  46.                             $header_image_height = HEADER_IMAGE_HEIGHT;
  47.                         }
  48.                         ?>
  49.                     <img src="<?php header_image(); ?>" width="<?php echo $header_image_width; ?>" height="<?php echo $header_image_height; ?>" alt="" />
  50.                 <?php endif; // end check for featured image or standard header ?>
  51.             </a>
  52.             <?php endif; // end check for removed header image ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement