Link to home
Start Free TrialLog in
Avatar of jbpeake
jbpeake

asked on

How to make jquery Galleria script autoplay

I have zero knowledge of jquery and javascript so please be patient with me on this question.

I downloaded and have successfully implemented the Galleria slideshow:
http://galleria.aino.se/
It really works great, I love it.

I would like to make it autoplay, and found this website that gives directions on how to do that.
http://stackoverflow.com/questions/2845312/galleria-auto-play-slideshow

In my very limited knowledge of java it looks like I need to paste the following code in to one of my files:

$('#galleria').galleria({
    extend: function() {
        this.play(4000); // will advance every 4th second
    }
});

But where do I need to put this code?  
This is the code as it appears on my current index.php file.

          <p>
              <!-- This gallery comes from:  http://galleria.aino.se/download/ -->
<div id="gallery">
    <img src="images/news_1.jpg">
    <img src="images/news_2.jpg">
    <img src="images/news_3.jpg">
    <img src="images/news_4.jpg">
</div>
<script>
    Galleria.loadTheme('galleria/themes/classic/galleria.classic.min.js');
          $("#gallery").galleria({
                        width: 440,
                        height: 308        
          });
</script>
          </p>

That works great, but when I add:


$('#galleria').galleria({
    extend: function() {
        this.play(4000); // will advance every 4th second
    }
});

it stops working.  So I looked around the other files to see if I needed to add that code to a different file, but I know so little java I really don't know what to do now.  Any help is appreciated.
Avatar of Tom Beck
Tom Beck
Flag of United States of America image

What if you change this:

<script>
    Galleria.loadTheme('galleria/themes/classic/galleria.classic.min.js');
          $("#gallery").galleria({
                        width: 440,
                        height: 308        
          });
</script>

To this:

<script>
    Galleria.loadTheme('galleria/themes/classic/galleria.classic.min.js');
          $("#gallery").galleria({
                        width: 440,
                        height: 308,
                        extend: function() {
                            this.play(4000);        
          });
</script>

Note that your id "gallery" is different than the id in the code you found, "galleria".
ASKER CERTIFIED SOLUTION
Avatar of Tom Beck
Tom Beck
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jbpeake
jbpeake

ASKER

Perfect, thanks!