• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Change front-page backstretch image for mobile width > Digital Pro

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › Design Tips and Tricks › Change front-page backstretch image for mobile width > Digital Pro

This topic is: resolved

Tagged: background image, backstretch, change background image, digital pro, mobile

  • This topic has 3 replies, 1 voice, and was last updated 10 years, 1 month ago by Ben Siegfried.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • March 7, 2016 at 7:55 pm #180863
    Ben Siegfried
    Participant

    How would I have the front-page backstretch image (that is above the fold) be replaced by a different image at 800px wide?

    Let's say we put the background image for mobile in the /images folder.

    From the front-page . php file:

    //* Enqueue scripts for backstretch
    		add_action( 'wp_enqueue_scripts', 'digital_front_page_enqueue_scripts' );
    		function digital_front_page_enqueue_scripts() {
    
    			$image = get_option( 'digital-front-image', sprintf( '%s/images/front-page-1.jpg', get_stylesheet_directory_uri() ) );
    
    			//* Load scripts only if custom backstretch image is being used
    			if ( ! empty( $image ) && is_active_sidebar( 'front-page-1' ) ) {
    
    				//* Enqueue Backstretch scripts
    				wp_enqueue_script( 'digital-backstretch', get_bloginfo( 'stylesheet_directory' ) . '/js/backstretch.js', array( 'jquery' ), '1.0.0' );
    				wp_enqueue_script( 'digital-backstretch-set', get_bloginfo('stylesheet_directory').'/js/backstretch-set.js' , array( 'jquery', 'digital-backstretch' ), '1.0.0' );
    
    				wp_localize_script( 'digital-backstretch-set', 'BackStretchImg', array( 'src' => str_replace( 'http:', '', $image ) ) );
    
    			}
    
    		}

    From the front-page . js file:

    jQuery(function( $ ){
    
    	// Set front page 1 height
    	var windowHeight = $( window ).height() - 90;
    
    	$( '.front-page-1' ) .css({'height': windowHeight +'px'});
    		
    	$( window ).resize(function(){
    	
    		var windowHeight = $( window ).height();
    	
    		$( '.front-page-1' ) .css({'height': windowHeight +'px'});
    	
    	});
    
    	// Local Scroll Speed
    	$.localScroll({
    		duration: 750
    	});
    
    });
    http://my.studiopress.com/themes/digital/#demo-full
    March 9, 2016 at 11:47 pm #181097
    Ben Siegfried
    Participant

    Here's the link, the site wasn't live when I made the post. For the time being I have changed opacity on the section .wrap with rgba at mobile size so you can read the text.

    Americastributetoparis.com

    March 11, 2016 at 2:49 pm #181228
    Ben Siegfried
    Participant

    Actually, here's the jquery for the backstretch from backstretch.set . js:

    jQuery(document).ready(function($) {
    
    	$(".front-page-1").backstretch([BackStretchImg.src]);
    
    });

    I've been trying a few different ways at these pages to no avail.

    https://stackoverflow.com/questions/29729678/serving-a-different-set-of-images-for-mobile

    http://www.sitepoint.com/switch-background-image-backstretch-js/

    March 11, 2016 at 3:19 pm #181232
    Ben Siegfried
    Participant

    So I'm trying the if/else statement below and the desktop backstretch image is working but the image set for mobile (800px) is not coming in. The console is giving a 404 (Not Found) for the mobile image.

    jQuery(document).ready(function($) {

    if (window.matchMedia("(max-width: 800px)").matches) {
    // phone
    $(".front-page-1").backstretch(["/images/americas-tribute-to-paris-mobile.png"]);

    } else {

    //tab or desktop
    $(".front-page-1").backstretch([BackStretchImg.src]);

    }

    });

  • Author
    Posts
Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘Design Tips and Tricks’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2026 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble