About Sridhar Katakam
I am an independent WordPress web consultant with 10 years of experience in WordPress theme installation, customization, administration, maintenance, support, documentation, troubleshooting and PSD/design to WP.
Genesis and WordPress Tutorials
Session expired
Please log in again. The login page will open in a new tab. After logging in you can close it and return to this page.
Sridhar, The link to Backstretch in your post doesn’t seem to work. I’m not clear. Does your function work with the plugin or in lieu of the plugin. I see a free plugin here: http://wordpress.org/plugins/easy-backstretch/ and a premium plugin for Genesis here: http://reaktivstudios.com/store/wp-backstretch/. I would like a free solution after already spending money for a premium theme (ithemes Builder).
The link to jquery.backstretch.min.js mentioned in step 1 works. WordPress plugin (free or paid) is not needed per my above article. Just follow the steps.
Very elegant, I am using something like this
add_action ( ‘genesis_header’, ‘add_banner_image’, 999999999);
function add_banner_image() {
if ( has_post_thumbnail() && (is_page() || is_single()) ) {
$background = wp_get_attachment_image_src( get_post_thumbnail_id( $page->ID ), ‘full’ );
echo ‘ ‘;
echo ‘ body.custom-background { background-image: none; } #bgnew { position: fixed; top: -50%; left: -50%; width: 200%; height: 200%; z-index: -9999; } #bgnew img { position: absolute; top: 0; left: 0; right: 0; bottom: 0; margin: auto; min-width: 50%; min-height: 50%;} ‘;
}
}
Let me try your solution.
Your solution works great, Looks really cool. Thanks a lot.
Hi Sridhar,
I am using also the backstretch in my theme (Agency-pro). I am wondering if this javascript also generate the color transition of the body like in my website (http://www.dereisverleidster.nl). Because I like to remove this styling.
Regards,
Kenneth
Hi Kenneth, Sorry to ask this non related question. I looked at the website and wonder how you made the boxes on the home page. They look great and it’s exactly what I need for the site I’m now building. Thanks!
Thanks! This really helped me out 🙂
If you don’t want to have the background images an all pages, put: ” && in_category(‘categoryname’) ” in the first if statement.
/C
I’d like to know how to add overlay pattern image using backstretch.js ?
thanks in advance.
Great tutorial! I set everything up and I want it to target my div #header_hero. The site is here: http://www.newgridpower.com/test-page/ And I think I have everything set up right. I have
jQuery(document).ready(function($) {
$("#header_hero").backstretch([BackStretchImg.src],{duration:3000,fade:750});
});
for backstretch-set.js and I had to modify the pathway a bit in the other file to get to my skin:
//* Enqueue Backstretch script
add_action( 'wp_enqueue_scripts', 'enqueue_backstretch' );
function enqueue_backstretch() {
//* Load scripts only on single Posts, static Pages and other single pages and only if featured image is present
if ( is_singular() && has_post_thumbnail() )
wp_enqueue_script( 'backstretch', get_bloginfo( 'url' ) . '/wp-content/thesis/skins/new-grid/js/jquery.backstretch.min.js', array( 'jquery' ), '1.0.0' );
wp_enqueue_script( 'backstretch-set', get_bloginfo('url').'/wp-content/thesis/skins/new-grid/js/jquery.backstretch.min.js' , array( 'jquery', 'backstretch' ), '1.0.0' );
wp_localize_script( 'backstretch-set', 'BackStretchImg', array( 'src' => wp_get_attachment_url( get_post_thumbnail_id() ) ) );
}
What am I missing? I see the image URL in the source code but it is not displaying on the site??
Thanks in advance!
Steve
Great tutorial! This worked out great for me. I was just curious if there was a way to set a maximum height on the backstretch image. I love the height on the desktop version of my site (http://journeydevsite.com/services/), but I’d like to decrease the height a bit for mobile devices. Is that change made in the jquery.backstretch.min.js file?
This helped out tremendously. I do have one question. Is there a way to set up a default image if a feature image isn’t set?
Thanks a lot for this tutorial, it helped a lot!
Thanks, this looks great. I do have a question though. How can I implement this without it being full sized? I would the featured backgorund image to be 800px X 400px, centred at the top of the page right under the header/navigation.
Hi, I have followed your tutorial, but I do not see any result. I am new with Genesis. I wonder if there’s something missing. Do you have any idea why the image could not see in the background?
Once again, Sridhar, you are the man! Love your site and your work…thanks!!!
Is there a way to merge this with blur.js? It’s working beautifully as is, but I would love to put some opacity and blur to the background.
Cheers
How would I set the backstretch to apply only on larger screens, and then display the featured image above the content on mobile displays?
Hey Nick,
You can achieve this with a little CSS within a media query. Something like this:
@media only screen and (max-width: 600px) {
.single .site-inner {
padding-top: 550px;
}
}
Hey Sridhar,
I followed this to a “T” and I am not seeing the intended result. No featured image loads in background. I get 2 JS errors. “Failed to load resource: the server responded with a status of 404 (Not Found)” for jquery.backstretch.min.js, and a “Uncaught TypeError: $(…).backstretch is not a function” for backstretch-set.js. I confirmed that both files are in the proper location. Any ideas?
Thanks in advance for any assistance.
-B
Please disregard my question above. Not sure how or why, but I have it working now.
Does anyone have a responsive solution to have the featured image scale, and not crop on smaller screens? Thanks in advance for any assistance!
Great tutorial! Looks great on desktop.
-B
You can try experimenting using background-size property with cover and contain values at various tablet/mobile widths like below:
In functions.php use this code instead: http://pastebin.com/raw/ARFSt7hM
and in style.css, sample CSS: http://pastebin.com/raw/HfvgtFa7
Essentially we are setting the featured image as background image for the body element instead of using Backstretch.
Hi Sridhar
Bit late to the party on this one. When I implement this, I get the full-screen background, but I also get horizontal and vertical scroll bars, which makes it possible to infinitely scroll up/down and left/right. Is there a fix for this?
http://focused-projects-co-uk.stackstaging.com/investment/
Hover over the main content area, until scroll bars appear, and you can use the mouse wheel (or shift + mouse wheel) to scroll forever.
Thanks
Dom
Hi Dom,
I just checked that page in Chrome and in Firefox on my Mac and don’t find the issue.
Is the problem still present? If so, in which browser on what platform?
Hi Sridhar
I’m on Chrome on a Mac. I’ve attached some screenshots so you can see what’s going on (hopefully).
https://ibb.co/jiY6BG
https://ibb.co/mDFa5b
https://ibb.co/jjdjyw
The right-hand scroll bar is there all the time, but if I place my cursor below the footer then I am able to infinitely scroll down. And if I hold shift and use the mouse-wheel, I can infinitely scroll to the right.
Does it happen in other browsers? Have you checked in Firefox and Safari?
Can you recheck in Chrome after updating it?
also, make sure you aren’t zoomed out.
Press Cmd + 0 while in Chrome.