• 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

Parallax Pro: add images to all backgrounds of home sections

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 › General Discussion › Parallax Pro: add images to all backgrounds of home sections

This topic is: resolved

Tagged: background image, parallax, theme customizer

  • This topic has 7 replies, 5 voices, and was last updated 8 years, 11 months ago by Chad.
Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • March 18, 2014 at 2:08 pm #95541
    pcgs51
    Member

    Working with Parallax Pro. I would like to add images to the even numbered sections and have them appear in the Customization window. I only see 1, 3 and 5 in the theme Appearance>Customize panel. I looked through the front-page.php, page-landing.php, functions.php and the js/parallax.js docs but don't see anything in any file that is specific to the even numbered sections.

    How do I allow background images for all in the Customization page?


    Thanks,
    pcgs51

    March 18, 2014 at 8:05 pm #95589
    Tom
    Participant

    This is interesting to me as it is more about theme building and integration for a result on the WP backend than about integration for a result on the frontend. It's far from standard filter and hook modifications, and I hope I'm not crossing some taboo Genesis/StudioPress boundary in offering these instructions.

    In other words: I've never done this before and there may very well be another, better way to do this. But this works for the result you want. Backup all of your files beforehand. Do this on a dev installation before attempting on a live install. All standard disclaimers apply. Fair warning.

    You are going to change some Javascript and some theme configuration files as well as style.css.

    In the folder "themes\parallax-pro\lib" look for 'output.php'. open this file and change line 17 to:
    $opts = apply_filters( 'parallax_images', array( '1', '2', '3', '4', '5' ) );

    In the folder "themes\parallax-pro\lib" look for 'output.php'. open this file and change line 52 to:
    $images = apply_filters( 'parallax_images', array( '1', '2', '3', '4', '5' ) );

    In 'style.css' change the section at line 1130 as follows, or add this to the bottom of the file:

    .home-section-1,
    .home-section-2,
    .home-section-3,
    .home-section-4,
    .home-section-5 {
        background-attachment: fixed;
        background-color: #fff;
        background-position: 0px 0px;
        background-repeat: no-repeat;
        -webkit-background-size: cover;
        -moz-background-size:    cover;
        background-size:         cover;
    }

    In the folder 'themes\parallax-pro\js' open the file 'parallax.js' and replace the contents with this code:

    jQuery(function( $ ){
    
    	// Enable parallax and fade effects on homepage sections
    	// MODIFIED for additional parallax image sections 2, 4
    	$(window).scroll(function(){
    
    		scrolltop = $(window).scrollTop()
    		scrollwindow = scrolltop + $(window).height();
    
    		$(".home-section-1").css("backgroundPosition", "0px " + -(scrolltop/6) + "px");
    
    		if( scrollwindow > $(".home-section-2").offset().top ) {
    
    			// Enable parallax effect
    			backgroundscroll = scrollwindow - $(".home-section-2").offset().top;
    			$(".home-section-2").css("backgroundPosition", "0px " + -(backgroundscroll/6) + "px");
    		}
    
    		if( scrollwindow > $(".home-section-3").offset().top ) {
    
    			// Enable parallax effect
    			backgroundscroll = scrollwindow - $(".home-section-3").offset().top;
    			$(".home-section-3").css("backgroundPosition", "0px " + -(backgroundscroll/6) + "px");
    
    		}
    
    		if( scrollwindow > $(".home-section-4").offset().top ) {
    
    			// Enable parallax effect
    			backgroundscroll = scrollwindow - $(".home-section-4").offset().top;
    			$(".home-section-4").css("backgroundPosition", "0px " + -(backgroundscroll/6) + "px");
    		}
    
    		if( scrollwindow > $(".home-section-5").offset().top ) {
    
    			// Enable parallax effect
    			backgroundscroll = scrollwindow - $(".home-section-5").offset().top;
    			$(".home-section-5").css("backgroundPosition", "0px " + -(backgroundscroll/6) + "px");
    
    		}
    
    	});
    
    });

    Go to the theme customizer and you should now find two additional controls for "Featured Section 2 Image" and "Featured Section 4 Image". Use them to upload your photos, save and try not to get vertigo from all of the parallax action happening. This *should* work with the appropriate image sizes.


    Choose your next site design from over 350 Genesis themes.
    [ Follow me: Twitter ] [ Follow Themes: Twitter ] [ My Favourite Webhost ]

    March 18, 2014 at 11:42 pm #95618
    pcgs51
    Member

    Thanks Tom!

    For the sake of anyone reading here I believe you meant to say for the second document that gets edited on line 52 that the file name is

    “themes\parallax-pro\lib\customize.php”

    But as for everything else— this is not only spot on and WORKS, I will be able to learn quite a bit from reviewing the code in these edits. My biggest problem was I'm working with a multisite and accidentally was looking in the wrong child theme for the files to edit and the lib directory and the js/parallax.js simply weren't there. DOH! But this helps me so very much. THANK YOU so very much!


    Thanks,
    pcgs51

    March 19, 2014 at 12:26 am #95623
    Tom
    Participant

    @pcgs51 You are correct about 'customize.php'! Thanks for catching that typo - wish I could correct it.

    Glad that this is of help to you.


    Choose your next site design from over 350 Genesis themes.
    [ Follow me: Twitter ] [ Follow Themes: Twitter ] [ My Favourite Webhost ]

    March 19, 2014 at 11:43 am #95712
    timryan
    Member

    Tom,

    This code seems to be great. What would the modification be to the parallax.js code if there are 7 sections (two additional)?

    Thanks!

    March 19, 2014 at 11:12 pm #95758
    Tom
    Participant

    @timryan : Assuming that you've already registered the additional widget areas, for each of the file modifications shown, just edit them to include the additional widget/section numbers. For the .js file, just repeat the pattern established in the code for the existing home-sections to add for 6 and 7.


    Choose your next site design from over 350 Genesis themes.
    [ Follow me: Twitter ] [ Follow Themes: Twitter ] [ My Favourite Webhost ]

    April 7, 2014 at 10:16 pm #98995
    MarkP
    Member

    Hi Tom,
    Many thanks for a great piece of code, works like a charm.
    Just curious, is there a way to modify the white background color that is visible behind the scrolling images? The white shows at the bottom of images as they scroll to the top, like a page behind the images?
    I've used all images sized same to 1600 x 1067 so the sizes are correct based on the theme setup info.
    Thanks again for helping add the images to the even areas!
    Mark

    April 8, 2014 at 6:11 am #99022
    Chad
    Member

    This is exactly what I'm looking for. Going to give it a go and will report back if it works.

  • Author
    Posts
Viewing 8 posts - 1 through 8 (of 8 total)
  • The topic ‘Parallax Pro: add images to all backgrounds of home sections’ is closed to new replies.

CTA

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

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2023 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