AdGuy
April 28, 2016, 4:22pm
1
Hello,
So, in the long run I want to be able to randomly generate different background videos upon refresh. I am of the understanding Weblog doesn’t have that function yet. In the meantime is there a way to randomly generate background GIFs?
Thanks in advance for the help!
samliew
(webflowexpert.com)
April 28, 2016, 5:05pm
2
If you can setup at least two layers of backgrounds and post your published link here, I can help you with the code.
AdGuy
April 28, 2016, 5:08pm
3
Cool.
Can you be a bit more specific as to what you need from me? I’m a novice at this stuff.
Thanks for the help!
samliew
(webflowexpert.com)
April 28, 2016, 5:14pm
4
Make a container to hold the backgrounds.
Make at least two divs with backgrounds as shown.
Instead of jpg, you can use gif.
1 Like
AdGuy
April 28, 2016, 5:19pm
5
Cool.
Is there a way to make it so a different GIF is randomly generated upon refresh?
samliew
(webflowexpert.com)
April 28, 2016, 5:25pm
6
Once you have done that, paste this in Page Settings > Custom Code > Footer Code:
<script>
var Webflow = Webflow || [];
Webflow.push(function() {
var bg = $('.background-wrap').children();
bg.eq( Math.floor(Math.random() * bg.length) ).show().siblings().remove();
});
</script>
2 Likes
AdGuy
April 28, 2016, 6:57pm
7
This worked great. Thanks.
Why couldn’t you do the same thing with video? It seems like you could, no?
samliew
(webflowexpert.com)
April 29, 2016, 2:24am
8
Yes, why not? The setup is the same.
but remember. whenever you put a background video, all videos will load. so your load time could be longer.
samliew
(webflowexpert.com)
April 29, 2016, 4:28am
10
They will start streaming, but it will almost immediately stop as the script will remove the element from the page.