How can I randomize a Nextgen Gallery Slideshow

Been googling for an hour now can’t find the answer to what feels like a simple question.

I have a very basic slideshow. I am using the shortcode to load it into the template page.

Read More

[nggallery id=1]

I have also customized the view file gallery.php. Pretty much I just pulled out all the extra stuff and just have the foreach loop.

I have tried using the php shuffle on the $images array but that doesn’t fix the problem.

shuffle($images);
foreach ( $images as $image ) :

Any other ideas?

Related posts

Leave a Reply

1 comment

  1. There’s a function defined in nggfunctions.php that you can use directly in the template page:

    /* nggShowRandomRecent($type, $maxImages, $template, $galleryId) - return recent or random images
     * 
     * @access public
     * @param string $type 'id' (for latest addition to DB), 'date' (for image with the latest date), 'sort' (for image sorted by user order) or 'random'
     * @param integer $maxImages of images
     * @param string $template (optional) name for a template file, look for gallery-$template
     * @param int $galleryId Limit to a specific gallery
     * @return the content
    */
    

    Or you can use this shortcode, defined in the shortcodes.php file:

     /**
     * Function to show a gallery of random or the most recent images with shortcode of type:
     * 
     * [random max="7" template="filename" id="2" /]
     * [recent max="7" template="filename" id="3" mode="date" /]
     * where 
     * - max is the maximum number of random or recent images to show
     * - template is a name for a gallery template, which is located in themefolder/nggallery or plugins/nextgen-gallery/view
     * - id is the gallery id, if the recent/random pictures shall be taken from a specific gallery only
     * - mode is either "id" (which takes the latest additions to the databse, default) 
     *               or "date" (which takes the latest pictures by EXIF date) 
     *               or "sort" (which takes the pictures by user sort order)
     * 
     * @param array $atts
     * @return the_content
     */