Skip to content
  • Recent
  • Tags
  • Popular
  • Users
  • Search
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse

Lay Theme Forum

K

Knudsn

@Knudsn
About
Posts
2
Topics
0
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Random Video Backgrounds on Homepage
    K Knudsn

    Thanks @Richard-Keith!
    Fingers crossed

    General Discussion

  • Random Video Backgrounds on Homepage
    K Knudsn

    @silviu said in Random Video Backgrounds on Homepage:

    hey @mariusjopen ~ thanks for replying

    i'm a total noob when it comes to web / wordpress environment , so please excuse if i'm missing something obvious .
    so what i understand from @spontans code , applied to my project is this

    if($("body").hasClass("slug-welcome")) {
    var videosrc = Math.floor(Math.random() * 2) + 1;
    var homeurl = 'http://telegraf.studio/wp-content/uploads/2020/02/'';
    videopath = homeurl+videosrc+'.mp4';
    $('video source').attr('src', videopath);
    }

    i've modified the slug-home2 on the first line to my page name : slug-welcome
    the math.floor is modified from 6 to 2 , in my case i would like to have just 2 movies in the folder
    the path is also changed to my media folder that contains the movies.

    should i also modify $ to JQuery ?

    where do i place this code ? i've read about custom css/html , but just adding this to custom html head dose not
    work .

    thanks

    Hey Silviu
    Did you solve it?

    I'm trying to get the above to work, but it seems like I'm missing something.

    <script>
    Frontend.GlobalEvents.on("newpageshown", function(layoutObj, type, obj) {
    if(JQuery("body").hasClass("slug-home")) {
    var videosrc = Math.floor(Math.random() * 3) + 1;
    var homeurl = 'http://hidden.com/wp-content/uploads/'2020/09/';
    videopath = homeurl+videosrc+'.mp4';
    JQuery('video source').attr('src', videopath);
    }
    });
    </script>

    Best,
    Christian

    General Discussion
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Recent
  • Tags
  • Popular
  • Users
  • Search