zenphoto forums » Usage Support

random pict of a dynamic album

(17 posts)
  • Started 2 years ago by vincent3569
  • Latest reply from acrylian

Tags:

  1. vincent3569

    Contributor
    Joined: Nov '08
    Posts: 661

    hi

    I want to make a dynamic album called "portfolio".
    I would like to display a random image taken in this album.

    the getRandomImagesAlbum() function needs the folder name from which to get the image, but there is no folder created for a dynamic album.

    so, how can I displayed a random image taken in a dynamic album ?

    thanks for your help

    Posted 2 years ago #
  2. Zenphoto development team
    sbillard

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

    Actually, if you look at that function you will see that the "album" parameter is defined as "mixed" and can be an object or folder. (http://www.zenphoto.org/documentation/functions/_template-functions.php.html#functiongetRandomImagesAlbum)

    so you pass it the album object.

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

    Contributor
    Joined: Nov '08
    Posts: 661

    hi

    could you help me to write the correct syntax to obtain the object of my dynamic album called "portfolio" ?

    I'm stuck on this thing since one week :-(

    thanks in advance.

    Posted 2 years ago #
  4. Zenphoto development team
    acrylian

    Developer
    Joined: Jul '07
    Posts: 13,367

  5. vincent3569

    Contributor
    Joined: Nov '08
    Posts: 661

    Thanks acrylian
    I have read it before posting, but the only way to create an album object is with the folder name of the album :
    $albumobject = new Album($galleryobject,"<folder name of the album>");

    how should i do to create an object from a dynamic album ?

    Posted 2 years ago #
  6. Zenphoto development team
    acrylian

    Developer
    Joined: Jul '07
    Posts: 13,367

    The same way. Since a dynamic album is not a folder you have to use its name. In your case probably "portfolio.alb".

    Don't forget to read the Forum rules and usage resources
    Posted 2 years ago #
  7. vincent3569

    Contributor
    Joined: Nov '08
    Posts: 661

    hi

    there is the code I try to implement :

    <div id="daily-image">
    <?php
    $gallery_object = new Gallery();
    $album_object = new Album($gallery_object,'Portfolio.alb');
    $image = getRandomImagesAlbum($album_object, true);

    if (is_object($image) && $image->exists) {
    echo '';
    echo '<img src="' . htmlspecialchars($image->getCustomImage(null, 400, null, null, null, null, null, true)) . '" alt="' . html_encode(gettext('Gallery')) . '"/>';
    echo '
    ';
    } ?>

    Image du jour
    </div>

    but it doesn't work : the random pic is taken from the whole gallery and not in my dynamic album.

    what's going wrong ?

    Posted 2 years ago #
  8. Zenphoto development team
    sbillard

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

    Since that is a dynamic album presumably the images could come from anywhere in the gallery.

    Don't forget to read the Forum rules and usage resources
    Posted 2 years ago #
  9. flu

    Contributor
    Joined: May '08
    Posts: 215

    Hi,
    maybe you could try something like that ?

    <?php printRandomImages(1,'daily-image','album','portfolio.alb','','',true);?>

    Posted 2 years ago #
  10. vincent3569

    Contributor
    Joined: Nov '08
    Posts: 661

    @flu : printRandomImages() have a call of getRandomImagesAlbum() if option = album
    according to me, the problem will be the same.

    @sbillard : I don't understand what you would say.
    My dynamic album have 10 pictures.
    Actually, the call of the function returns other pictures than de 10 ones of my dynamic album.

    where is the problem ?

    Posted 2 years ago #
  11. flu

    Contributor
    Joined: May '08
    Posts: 215

    It works very fine for me that way :
    I get random pics from my dynamic album without problem.
    Did you try it ?

    Cheers.

    Posted 2 years ago #
  12. vincent3569

    Contributor
    Joined: Nov '08
    Posts: 661

    @flu
    you are right :

    <?php printRandomImages(1,'daily-image','album','portfolio.alb','','',true);?> works well

    and <?php
    $gallery_object = new Gallery();
    $album_object = new Album($gallery_object,'Portfolio.alb');
    $image = getRandomImagesAlbum($album_object); ?>
    works well too

    but if I want daily picture it doesn't work : the random pic is taken from the whole gallery and not in my dynamic album.

    => the daily option seems to cause an issue.

    Posted 2 years ago #
  13. vincent3569

    Contributor
    Joined: Nov '08
    Posts: 661

    I have created a ticket http://www.zenphoto.org/trac/ticket/1834

    Posted 2 years ago #
  14. js0624

    Apprentice
    Joined: May '11
    Posts: 3

    Can we list the photo from dynamic album rather than random, cause I followed the codes given by @vincent3569 it is working yet I don't know how can I list all the photos of dynamic album.

    What I mean is? Is there any functions that says getImagesAlbum, to list down all the contents of the dynamic album, instead of random. Thanks.

    Posted 2 years ago #
  15. Zenphoto development team
    acrylian

    Developer
    Joined: Jul '07
    Posts: 13,367

    js0624, why do you post the same question of your topic on another thread? Did you even bother to look at the documentation? How about $object->getImages() maybe?

    Of course dynamic albums are special as the images still belong to their real albums.

    Don't forget to read the Forum rules and usage resources
    Posted 2 years ago #
  16. js0624

    Apprentice
    Joined: May '11
    Posts: 3

    Hi acrylian, my apology, I thought it is much clearer if I will post it here... I tried your code and it works, that's what I am looking for... I have another problem, if you don't mind. I have noticed that only filename and folder is available, how can I get the permalink of the photos? Thanks in advance.

    Posted 2 years ago #
  17. Zenphoto development team
    acrylian

    Developer
    Joined: Jul '07
    Posts: 13,367

    It comes all down to this: http://www.zenphoto.org/news/zenphotos-object-model-framework

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

RSS feed for this topic

Reply

You must log in to post.