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

  1. Home
  2. General Discussion
  3. Random intro image

Random intro image

Scheduled Pinned Locked Moved General Discussion
18 Posts 10 Posters 1.3k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M michael_vvc

    … was looking for this feature as well. would be great to have this option in the future :crystal_ball:

    A Offline
    A Offline
    Arthur
    wrote on last edited by
    #8

    @yaradria @michael_vvc just came across this (know its an old question) –
    one way to do this is as follows

    Make sure intro image is ON.
    into 'custom HTML at bottom', you can add/edit the following script
    (change '34' to relate to your homepage ID)
    (add your image urls from media library into the var of images...

    <script>
    var images = ['https://yourwebsite.com/image-url', 'https://yourwebsite.com/image-url-2', 'https://yourwebsite.com/image-url-3', ];

    var randomImage = Math.floor(Math.random() * 3)

    window.laytheme.on("newpageshown", function(layoutObj, type, obj){
    if(type == "page" && obj.id == 34){
    jQuery(".mediawrap").css("background-image", "url('" + images[randomImage] +"')");
    } else {
    jQuery(".mediawrap").css("background-image", "")
    }
    });
    </script>

    1 Reply Last reply
    0
    • RichardR Offline
      RichardR Offline
      Richard
      Global Moderator
      wrote on last edited by
      #9

      Awesome thank you @Arthur ! 💥

      1 Reply Last reply
      0
      • L Offline
        L Offline
        Loris
        wrote on last edited by Loris
        #10

        Hi @Arthur, this doesn't work for me.
        I have change the homepage ID, but none of images are showing up.
        Links to my images seem to be good… I don't know how to solve that.
        Any idea ?
        Thanks for helping
        Loris

        1 Reply Last reply
        0
        • RichardR Offline
          RichardR Offline
          Richard
          Global Moderator
          wrote on last edited by Richard
          #11

          Dear @Loris

          Could you please post a link to your website with 'random intro image' applied to better inspect it 🌝


          Best wishes & talk soon
          Richard
          1 Reply Last reply
          0
          • R Offline
            R Offline
            Remco van Dun
            wrote on last edited by
            #12

            @Richard said in Random intro image:

            random intro image

            Hi @Arthur and @Richard,

            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.

            R 1 Reply Last reply
            0
            • R Remco van Dun

              @Richard said in Random intro image:

              random intro image

              Hi @Arthur and @Richard,

              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.

              R Offline
              R Offline
              Remco van Dun
              wrote on last edited by
              #13

              @Richard

              My website is www.remcovandun.nl
              Can you see if anything's wrong?

              1 Reply Last reply
              0
              • RichardR Offline
                RichardR Offline
                Richard
                Global Moderator
                wrote on last edited by Richard
                #14

                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
                1 Reply Last reply
                0
                • R Offline
                  R Offline
                  Remco van Dun
                  wrote on last edited by
                  #15

                  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?

                  1 Reply Last reply
                  0
                  • R Offline
                    R Offline
                    Remco van Dun
                    wrote on last edited by
                    #16

                    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>
                    
                    1 Reply Last reply
                    1
                    • K Offline
                      K Offline
                      kalamakumaran
                      wrote on last edited by
                      #17

                      @Remco-van-Dun

                      Cheers!

                      1 Reply Last reply
                      0
                      • RichardR Offline
                        RichardR Offline
                        Richard
                        Global Moderator
                        wrote on last edited by Richard
                        #18

                        @Remco-van-Dun Thank you! 💥

                        1 Reply Last reply
                        1
                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                        I also code custom websites or custom Lay features.
                        💿 Email me here: 💿
                        info@laytheme.com

                        Before you post:
                        1. When using a WordPress Cache plugin, disable it or clear your cache.
                        2. Update Lay Theme and all Lay Theme Addons
                        3. Disable all Plugins
                        4. 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:
                        1. Post a link to where the problem is
                        2. Does the problem happen on Chrome, Firefox, Safari or iPhone or Android?
                        3. If the problem is difficult to explain, post screenshots / link to a video to explain it
                        Online Users
                        Forgot your key, lost your files, need a previous Lay Theme or Addon version? Go to www.laykeymanager.com
                        laytheme.com
                        • Login

                        • Don't have an account? Register

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