I’ve used NextGen gallery for WordPress quite a bit and it’s a nice plugin. BUT… I’ve always wanted to be able to do ‘easy embed’ multiple jquery slideshows that show images in a RANDOM order. (This IS possible using the Flash slideshow component but I don’t always want/need to use Flash for this).
The non-Flash (jQuery) slideshow component is currently quite basic, and after much hunting around it was looking like this simple requirement would be difficult to implement.

I have, however, found a simple hack for this. It does involve editing one of the plugin JS files though, which isn’t ideal (e.g. future plugin upgrades may well overwrite this change). But this instruction might help someone out – and might persuade someone more technical to extend the core plugin in some way.

Firstly, set up your working slideshow (I use the [ slideshow id=x width=a height=b ] shortcode to embed it in a page or post).
Next, to make this slideshow random edit the nextgen-gallery/js/ngg.slideshow.min.js file (from dashboard plugins>editor and find this JS file)
Find this snippet “cycle({fx:s.fx,containerResize:1,fit:1,” and immediately after this add
where x is the number of slides in your gallery

1) this will affect ALL slideshows in your site i.e. will make them all random
2) it’s not truly random, it follows the usual slide order, just randomises the *starting slide* (then wraps around at the end).
3) if you have multiple slideshows of multiple galleries in your site the value of x might become a problem as it’s a hardcoded global variable. Best option here would be to keep x the same as the number of slides in the smallest gallery.
4) in the same JS file i also changed “jQuery(obj+’ img:first’).fadeIn(1000,” to “jQuery(obj+’ img:first’).fadeIn(0,” to stop the slide 1 in the gallery showing up on page load. This *might* cause an issue on slow connections?

If anyone can improve this please do!
I would LOVE it if i could simply do something like [ slideshow id=x random=true ]

One Comment

Leave a Reply

Your email address will not be published. Required fields are marked *