Random intro image
-
@Richard said in Random intro image:
random intro image
I've tried a lot but cant seem to get the page ID right? Am i not seeing the right ID perhaps?
When i was messing around and I changed the number to 105, 81 I was able to apply it to my background... so I felt like it at least worked.
-
My website is www.remcovandun.nl
Can you see if anything's wrong? -
Dear @Remco-van-Dun
Do you currently have any intro image's chosen or is this the issue; That you cannot see your Intro image that you have chosen.
Do you have functional issue with your Intro? or you just wish to apply to 'Random Image code' properly.
Just wish to clarify as there are a few sides to this thread 🌝
Have a wonderful day & Best wishes
Richard
-
Thanks for the reply @Richard
I currently have 3 images set and intro feature is turned on / added custom html at bottom.
I think I can't find my correct page ID for it to work (could you)? While I was looking for the right ID found 105, 81 which I also tried separately, but together they made my page bg change. So the code seems to work but just not where it's supposed to?
-
With some help of a friend I've found a (hacky) way.
Although it requires a fully transparent .png to be set in your customize > intro
Because without a file, it won't trigger the intro feature? And a normal image will of course cover up your random set intro images...in Custom HTML at bottom:
<script> var images = [ 'http://yourwebsite.com/image1.jpg', 'http://yourwebsite.com/image2.jpg', 'http://yourwebsite.com/image3.jpg' ]; var randomImage = Math.floor(Math.random() * images.length) window.laytheme.on("newpageshown", function(layoutObj, type, obj){ if (obj.id == 1) { var mediaWrap = jQuery(".mediawrap"); mediaWrap.css("background-image", "url('" + images[randomImage] +"')"); mediaWrap.css("background-size", "cover"); } }); </script>
-
Cheers!
-
@Remco-van-Dun Thank you! 💥
Before you post:
- When using a WordPress Cache plugin, disable it or clear your cache.
- Update Lay Theme and all Lay Theme Addons
- Disable all Plugins
- Go to Lay Options → Custom CSS & HTML, click "Turn Off All Custom Code", click "Save Changes"
This often solves issues you might run into
When you post:
- Post a link to where the problem is
- Does the problem happen on Chrome, Firefox, Safari or iPhone or Android?
- If the problem is difficult to explain, post screenshots / link to a video to explain it