In my head this sound right. I check if the post has a thumbnail. If it has, I assign the post thumbnail to a variable that I call as the source for my background image. If the post does not have a thumbnail, I assign a placeholder image as the background.
However, I'm having some issues :/
The code block below breaks my site, and if I change the else
statement to $large_image_url = bloginfo('template_directory')?>/library/images/default-header-image.jpg<?php;
it actually echoes out the variable as a line of text instead of saving it in the variable.
<?php
if ( has_post_thumbnail() ) {
$large_image_url = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), '' );
} else {
$large_image_url = bloginfo('template_directory')'/library/images/default-header-image.jpg';
} ?>
<section class="header-image" style="background-image: url('<?php echo $large_image_url[0] ?>');">
</section>
Can someone give me a push in the right direction?