In the comments section of How to set Featured Image as Header's background using Backstretch in Genesis a user asked:
I’m curious how this concept could be integrated with Monochrome Pro. For single posts, it’s already using it’s own backstretch between the site-header and site-inner with the author’s user profile image overlaid, but only if the post has a featured image. I would love to set a default backstretch/image and display the author profile image even if there is not a featured image.
When viewing single Post pages in Monochrome Pro, if a featured image is present, the post page will appear with a user gravatar and the content seemingly being pulled on top of the image.
For posts that do not have a featured image, the post page will appear without the user gravatar and any image.
We can set a fallback image (from images directory) to appear for posts that do not have a featured image so there is consistency in the appearance of single posts.
Step 1
Upload your desired fallback image (1600 x 600 recommended) to Monochrome Pro's images directory as say, single-default.jpg.
Step 2
Edit single.php.
Change
To view the full content, please sign up for the membership.
Already a member? Log in below or here.
Thank you so much for this! Everything went smoothly until part D, which gave me an empty div.entry-background on posts with or without featured images. After some trial and error, and re-reading your original post, I finally landed on
if ( has_post_thumbnail() ) {
for part D that seems to work.$featured_image_url = wp_get_attachment_url( get_post_thumbnail_id() );
$image = array( 'src' => $featured_image_url );
} else {
$default_single_url = get_stylesheet_directory_uri() . '/images/single-default.jpg';
$image = array( 'src' => $default_single_url );
}
wp_localize_script( 'monochrome-backstretch-set', 'BackStretchImg', $image );
Sridhar,
Can you do a tutorial on how to apply a featured image or fallback image for pages? I’d like to have individual featured image display on each page instead of the same fallback image. How can I go about applying this to Monochrome Pro? Thanks!
So you want the featured image to appear full-width between the fixed header (.site-header) and Page content (.site-inner), correct?
I’d like to see this as well. By the way, is there any way to add background without the gravatar?
So you want the featured image to appear full-width between the fixed header (.site-header) and Page content (.site-inner), correct?
Should the site inner be pulled up?
For single posts?
Yes, that’s right.
Actually, this is what I’d really like to see, but with the Monochrome Pro theme. 🙂
Here’s the link: https://sridharkatakam.com/featured-image-header-pages-posts-entry-header-overlay-infinity-pro/
I just published this. See if it helps..
https://sridharkatakam.com/featured-image-header-pages-posts-entry-header-overlay-monochrome-pro/