Skip to content

Instantly share code, notes, and snippets.

@psflannery
Created June 23, 2013 18:35
Show Gist options
  • Save psflannery/5846007 to your computer and use it in GitHub Desktop.
Save psflannery/5846007 to your computer and use it in GitHub Desktop.
Sets the thumbnail image as background to a div
<header class="entry-header row" <?php
if ( $thumbnail_id = get_post_thumbnail_id() ) {
if ( $image_src = wp_get_attachment_image_src( $thumbnail_id, 'x-large-size' ) )
printf( ' style="background-image: url(%s);"', $image_src[0] );
}
?>>
<?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'large' );
$image = $image[0]; ?>
<div id="primary" class="content-area fader" style="background-image: url('<?php echo $image; ?>');">
<div id="content" class="site-content" role="main">
<?php get_template_part( 'content', 'home' ); ?>
</div><!-- #content -->
</div><!-- #primary -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment