I am having a little trouble displaying a default image as a background image when a feature image is not present. This is the code I am using
<?php if (has_post_thumbnail( $post->ID ) ): ?> <?php $src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), array( 5600,1000 ), false, '' );?> <?php else : $src = get_bloginfo( 'stylesheet_directory') . '/lib/images/home1-1024x681.jpg'; ?> <?php endif; ?> <section id="halfpro" style="background:url(<?php echo $src; ?> ) no-repeat center center">
When I upload a feature image it works but when I do not have one selected the div is empty. When I look at the source it seems as though it is not rendering the URL correctly, I am getting this background:url(h ).
What am I missing?