Random album cover
knorde
Joined: 2010-02-02
Posts: 64 |
Posted: Fri, 2012-05-25 11:14 |
Hi, On this forum i found the code to use random album covers. Anyway the random album covers works fine only if in the subalbum are pictures. If in the album only subalbums (and in the subalbums are pictures) the album pictures will not random. The code i used (in album.html.php) is: <?= $theme->thumb_top($child) ?> <? if ($child->is_album() && ($rnd = item::random_query()->where("parent_id", "=", $child->id)->find()) && $rnd->loaded()): ?> <a href="<?= $child->url() ?>"> <? if ($rnd->has_thumb()): ?> <? if ($rnd->thumb_height >= $rnd->thumb_width): ?> <?= $rnd->thumb_img(array("class" => "g-thumbnail")) ?> <? else: ?> <?= $rnd->thumb_img(array("class" => "g-thumbnail2")) ?> <? endif ?> <? endif ?> </a> <? else: ?> <a href="<?= $child->url() ?>"> <? if ($child->has_thumb()): ?> <? if ($child->thumb_height >= $child->thumb_width): ?> <?= $child->thumb_img(array("class" => "g-thumbnail")) ?> <? else: ?> <?= $child->thumb_img(array("class" => "g-thumbnail2")) ?> <? endif ?> <? endif ?> <? endif ?> </a> On this moment only the subalbums will have random album covers. Greets Kees. |
|
Posts: 64
No one?
Posts: 76
Nice work - looking for something like this myself.
how often does the random image change?
Posts: 64
Every time on page reloading.
Posts: 64
Any one any idea?
Posts: 27300
So you are looking to get a random item from all items in a album including the children and grandchildren of a particular album?
I'm not good with SQL queries but should be able to check for all items that have left and right pointers of related values.
->where("left_ptr", ">", $this->left_ptr)
->where("right_ptr", "<", $this->right_ptr)
I'm sure there is some other module that gathers similar info.
I'll see what I can find later tonight.
Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team
Posts: 64
Thanks for the reply
When i use:
or
it randomize the whole album (not only the subalbums in the album (as example) vakantie).
I mean that the thumbnail image for the album is a random image selected from all the images in the sub-albums of that parent album
Posts: 27300
You will need to look at the DB for the left and right pointers perhaps you need to be => or =< and not just > or <.
or you may need to search for the parent left and right pointers of the parent and not the child.
Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team