NextGEN Gallery slideshow with Navigation

Green Light Blog

NextGEN Gallery slideshow with Navigation

NOTE: This post was written nearly 6 years ago initially. I don’t implement this particular solution any longer, but I’m leaving it up in case it points somebody in a useful direction in the future…

I’m using the free version of the WordPress NextGEN gallery, which by the way, is a pretty great plugin. Ā I wanted to use the slideshow, but wanted to have navigation attached to it. Ā The slideshow in the free version of NextGEN gallery doesn’t have the navigation. Ā I particularly like the navigation used in the Superslides jquery plugin. Ā So for what it’s worth, here’s what I did…

In the plugin file structure, there’s a folder for the modules, the types of ā€œproductsā€ that NextGEN has. Ā Within the nextgen_basic_gallery folder, there’s a templates folder, and there is a slideshow folder in that folder. Ā This holds the code for the basic slideshow that comes with NextGEN.

Ignoring the ā€œflash outputā€ section, move to the next section of code, commented with ā€œDisplay JQuery Cycle Slideshowā€. Ā In this section, there is a ā€œforā€ loop. Ā This loop is cycling through the images, and writing something for each one. Ā I changed that to only spit out the <img> tag information, since the Superslides.js plugin doesn’t need any more than that regarding images. Ā I also surrounded the ā€œforā€ loop with the <div id=ā€slidesā€>[for loop]</div> that Superslides needs.

Additionally I added a div with some style attached to it, and wrapped it around the ā€œslidesā€ div, so that I could use the Superslide inherit_width_from and ā€œinherit_height_fromā€ parameters to constrain the size and location of the slideshow.

After the loop is done, I just tossed in the navigation using ā€œFont Awesomeā€. Ā Be sure to include Font Awesome in your master styles.

<nav class="slides-navigation">
 <a href="#" class="next"><i class="fa fa-chevron-right"></i></a>
 <a href="#" class="prev"><i class="fa fa-chevron-left"></i></a>
 </nav>

Next, I tossed in the required Superslides code to make the whole thing work…

<script src="path/to/wp-includes/js/superslides/jquery.easing.1.3.js"></script>
 <script src="path/to/wp-includes/js/superslides/jquery.animate-enhanced.min.js"></script>
 <script src="path/to/wp-includes/js/superslides/jquery.superslides.js" type="text/javascript" charset="utf-8"></script>
<script>
 jQuery(function() {
 jQuery('#slides').superslides({
 inherit_width_from: '.someslideeshow',
 inherit_height_from: '.someslideeshow',
 hashchange: true,
 play: 5000
 });
jQuery('#slides').on('mouseenter', function() {
 jQuery(this).superslides('stop');
 console.log('Stopped')
 });
 jQuery('#slides').on('mouseleave', function() {
 jQuery(this).superslides('start');
 console.log('Started')
 });
 });
 </script>

The result is a navigable, paginated slideshow, utilizing NextGEN’s awesome gallery plugin, but styled with the Superslides navigation that I like.

When NextGEN updates, I’ll need to fix the plugin again, but the work is minimal, as long as you’re comfortable writing minimum PHP and Javascript. Ā I could probably extend the plugin to take advantage of this new ā€œtemplateā€, but I really can’t be bothered to do that at this time. Ā I’m happy with what I needed to accomplish. Ā Maybe I’ll do that in the future, to help future-proof the slideshow, and make it available as a NextGEN template for others to use. Ā We’ll see what kind of time I have, or if it’s worth it to anybody else.

I hope this helps somebody else out there who has the same question I did.

jtruschke