We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 14020
    • 75 Posts
    This is a topic for randImages by jerry325

    DESCRIPTION

    This Snippet retrieves a selected number of random image files from a
    directory, processes them through a template chunk and returns the results.

    PARAMETERS:

    &ri_Folder string - The name of the image folder to search. optional. Default: assets/photos
    &ri_Tpl string - The name of a Chunk used to format output. optional. Default: ri_Tpl
    &ri_Quantity integer - A number representing how many images to return. optional. Default: 5
    if number exceeds files in the folder all will be returned
    &ri_Ext string - The name of the image extension(s) to search for. Default: jpg
    &ri_Width integer - A number representing the width images to return. optional. Default: 150
    &ri_Height integer - A number representing the height images to return. optional. Default: 100
    &ri_Border integer - A number representing the border around the images to return. optional. Default: 0
    &ri_Class string - A class name to pass. optional. Default: ''

    USAGE:

    [[!randImages]]

    USAGE - Advanced:

    [[!randImages?
    &ri_Folder=`assets/photos/*`
    &ri_Tpl =`ri_Tpl`
    &ri_Quantity=`5`
    &ri_Ext =`jpg`
    &ri_Width =`150`
    &ri_Height=`100`
    &ri_Border=`2`
    &ri_Class =`image`
    ]]
    *All vars are optional

    Release Notes
    I put this little snippet together from bits and pieces of my getImages snippet so I could
    tease my audience with a sample of the images in a folder. Thanks to "sottwell" for suggesting
    that I package it up for the rest of the world. One interesting note is that the way glob
    works you can insert an * anywhere you need to in the path to get to the folders you want to
    include. Be careful though as this may lead to some long processing times if you have
    hundreds of images. As always I would be grateful for any and all suggestions for improvements.
    Support/Comments should be posted here!