Community Forums › Forums › Archived Forums › General Discussion › Parallax Pro: add images to all backgrounds of home sections
Tagged: background image, parallax, theme customizer
- This topic has 7 replies, 5 voices, and was last updated 9 years, 5 months ago by
Chad.
-
AuthorPosts
-
March 18, 2014 at 2:08 pm #95541
pcgs51
MemberWorking 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,
pcgs51March 18, 2014 at 8:05 pm #95589Tom
ParticipantThis 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 #95618pcgs51
MemberThanks 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,
pcgs51March 19, 2014 at 12:26 am #95623Tom
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 #95712timryan
MemberTom,
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 #95758Tom
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 #98995MarkP
MemberHi 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!
MarkApril 8, 2014 at 6:11 am #99022Chad
MemberThis is exactly what I'm looking for. Going to give it a go and will report back if it works.
-
AuthorPosts
- The topic ‘Parallax Pro: add images to all backgrounds of home sections’ is closed to new replies.