Daily Random Image from Specific Album?

I'd like to add a random image from a specific album that changes daily. I've gotten the printrandomimages function to work, but I don't see anything in there about making it daily. I see getRandomimages function, which has daily, but nothing else. I see getRandomImagesAlbum, which has a specific album.

I think there is probably a way to combine the functions to show a daily random image from a specific album, but I don't know how to do it. Can anyone suggest the possible code that could be used?

Thanks in advance!!

Comments

  • The code that handles the daily image is
    `
    if ($daily) {
    $potd = unserialize(getOption('picture_of_the_day'));
    if (date('Y-m-d', $potd['day']) == date('Y-m-d')) {
    $album = new Album($_zp_gallery, $potd['folder']);
    $image = newImage($album, $potd['filename']);
    if ($image->exists) return $image;
    }
    }
    `
    You could create a new custom function that incorported this code. The fallthrough should use the getRandomImageAlbum() function to get a new image and then

    `
    if ($daily) {
    $potd = array('day' => time(), 'folder' => $result['folder'], 'filename' => $imageName);
    setOption('picture_of_the_day', serialize($potd));
    }
    `
    To save off the new image.

    This code has all been extracted from the `getRandomImages()` function.
  • Thanks for the rapid response. Still struggling to get it working, but hopefully will have success.
Sign In or Register to comment.