zenphoto forums » General Zenphoto Discussion

getting X random images from a given album

(4 posts)
  • Started 4 years ago by typenerd
  • Latest reply from sbillard
  1. typenerd

    Member
    Joined: Sep '08
    Posts: 12

    Hi there,

    I'm using this currently to get one random image at a time, but I'd like to get 4. How can I get 4 random images that are all different?


    while (next_album()):
    // random images
    makeImageCurrent(getRandomImagesAlbum(getAlbumTitle()));
    echo '';
    printImageThumb(getAnnotatedImageTitle());
    echo '
    ';
    endwhile;

    Posted 4 years ago #
  2. Zenphoto development team
    sbillard

    Chief Developer
    Joined: May '07
    Posts: 9,823

    First, the album title is not an appropriate parameter for the getRandomImagesAlbum() function. Please read the functions guide for parameter documentation.

    Baring that, your code will print one random image from each album. If you want that but want to stop at 4, you will need a counter and break in the loop. If you want 4 arbitrary random images you can use printRandomImages() function.

    Remember, however, the definition of random is that it may select any image, includign one that has been selected before. If you want to insure you have unique images you will have to add that test to your loop.

    Don't forget to read the Forum rules and usage resources
    Posted 4 years ago #
  3. typenerd

    Member
    Joined: Sep '08
    Posts: 12

    Thanks for the help; I see where I was going wrong.

    I'm trying to output random images but of a different size than my thumbnails; what's the best function to use for that? I'd prefer my images to be cropped to squares (they're a mix of portrait and landscape).

    Posted 4 years ago #
  4. Zenphoto development team
    sbillard

    Chief Developer
    Joined: May '07
    Posts: 9,823

    Do you want it to behave as a thumbnail? Or do you just want the image?

    Anyway, there are custom thumbnail/image functions one of which will I am sure do the trick. Search the function guide for customImage

    Don't forget to read the Forum rules and usage resources
    Posted 4 years ago #

RSS feed for this topic

Reply

You must log in to post.