WordPress.org

Support

Support » Plugins and Hacks » Slideshow » [Resolved] Make random option display all slides before repeating

[Resolved] Make random option display all slides before repeating

  • I’ve been using Slideshow 2.2.7 on my front page for the last few days, and it’s working great: about 15 photos cycling, in random mode, so visitors almost always have a fresh photo each time they visit.

    However: the current implementation seems to choose a purely random slide to display whenever the slide timer expires. This means that photos often repeat within two or three transitions, so visitors think there are fewer unique photos than there actually are.

    I’d prefer a shuffle algorithm, where a random order for the slides is chosen at the initial page load, but all slides get displayed once before any repeats show up. The order could be reshuffled each time the full set has been shown.

    Thanks,

    Eddy

    http://wordpress.org/extend/plugins/slideshow-jquery-image-gallery/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Stefan Boonstra

    @stefanboonstra

    Hi Eddy,

    This is a great idea, thanks!

    I’ve also received a request, asking to remember the slides that the slideshow has gone through previously. These updates will fit together very nicely.

    I expect to be able to include them in a minor update like version 2.2.8 or 2.2.9.

    Thanks for the suggestion!

    Best regards,
    Stefan

    Hacked this into getNextViewId() of slideshow.min.js in case anyone else needs it:
    Also requires adding var randomShuffle =[]; to the top of slideshow.min.js and the shuffle function below:

    function getNextViewId(){
    	if($settings['random']){
    		if (randomShuffle.length === 0) {
    			for (index = 0; index < $views.length; ++index) {
    				randomShuffle.push(index);
    			}
    			shuffle(randomShuffle);
    			return randomShuffle[0];
    		}
    		var viewId=$currentViewId;
    		var shuffler = randomShuffle.indexOf(viewId);
    		shuffler++;
    		if(shuffler > randomShuffle.length-1){
    			return randomShuffle[0];
    		} else {
    			return randomShuffle[shuffler];
    		}
    	}
    	var viewId=$currentViewId;
    
    	if(viewId==undefined)return 0;
    
    	if(viewId>=$views.length-1){
    		if($settings['loop'])
    		return viewId=0;
    		else return $currentViewId
    	}
    	return viewId+=1
    }
    
    function shuffle(array) {
       var tmp, current, top = array.length;
    
       if(top) while(--top) {
       	current = Math.floor(Math.random() * (top + 1));
       	tmp = array[current];
       	array[current] = array[top];
       	array[top] = tmp;
       }
    
       return array;
    }
    Plugin Author Stefan Boonstra

    @stefanboonstra

    Very nice work, Rzah! The improved randomization will probably be available in the next version, version 2.2.12.

    Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Resolved] Make random option display all slides before repeating’ is closed to new replies.
Skip to toolbar