Parallax Pro: add images to all backgrounds of home sections

Community Forums Forums General Discussion Parallax Pro: add images to all backgrounds of home sections

This topic is: resolved

This topic contains 7 replies, has 5 voices, and was last updated by  Chad 6 months, 2 weeks ago.

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #95541

    pcgs51
    Participant
    Post count: 28

    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

    • This topic was modified 7 months, 1 week ago by  pcgs51.
    • This topic was modified 7 months, 1 week ago by  pcgs51.
    #95589

    Tom
    Participant
    Post count: 941

    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.
    Updates via GenesisThemes.ca | Twitter | Google+ | Tumblr

    #95618

    pcgs51
    Participant
    Post count: 28

    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

    #95623

    Tom
    Participant
    Post count: 941

    @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.
    Updates via GenesisThemes.ca | Twitter | Google+ | Tumblr

    #95712

    timryan
    Member
    Post count: 8

    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!

    #95758

    Tom
    Participant
    Post count: 941

    @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.
    Updates via GenesisThemes.ca | Twitter | Google+ | Tumblr

    #98995

    MarkP
    Member
    Post count: 27

    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

    #99022

    Chad
    Participant
    Post count: 8

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

    • This reply was modified 6 months, 2 weeks ago by  Chad.
    • This reply was modified 6 months, 2 weeks ago by  Chad.
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.