Grow your CSS skills. Land your dream job.

random images

  • # August 24, 2009 at 4:34 pm

    is there a way of adding a script to randomly pick images from a folder. What i need is a new image everytime someone visits the homepage.

    At the moment its setup to output images using a custom field in wordpress but i can not find somthing to get it to pick random photo’s on each visit.

    Any help would be great.

    Thanks

    B

    Rob
    # August 24, 2009 at 4:41 pm

    Here ya go :)

    viewtopic.php?f=6&t=3986

    # August 26, 2009 at 5:16 pm

    as rob has said, that thread has a few ideas, mine is best though ;)

    # August 27, 2009 at 7:39 am

    I use

    Code:
    < ?php
    function randomImage ( $array ) {
    $total = count($array);
    $call = rand(0,$total-1);
    return $array[$call];
    }
    $my_images = array (
    "com.jpg",
    "image.jpg",
    "etc.jpg"
    );
    $img = randomImage($my_images);
    ?>

    < ?php echo '‘; ?>

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".