WordPress.org

Ready to get started?Download WordPress

Forums

Slideshow
[resolved] Make random option display all slides before repeating (4 posts)

  1. eddycarroll
    Member
    Posted 1 year ago #

    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/

  2. Stefan Boonstra
    Member
    Plugin Author

    Posted 1 year ago #

    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

  3. Rzah
    Member
    Posted 1 year ago #

    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;
    }
  4. Stefan Boonstra
    Member
    Plugin Author

    Posted 1 year ago #

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

    Thanks!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.