Random album cover

knorde

Joined: 2010-02-02
Posts: 64
Posted: Mon, 2012-06-18 13:53

Hi,

It will be nice to have random album covers (thumbs).
It will be nice that the thumbnail image for the album is a random image selected from all the images in all the sub-albums of that parent album (if in the album only subalbums (and in the subalbums are pictures) the album pictures will taken from the subalbums random).

Is there any option for this?

I tryed to code it by myself.
But i get it only work with all the images (from other parent albums to) and not the above option.

Greets Kees.

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Mon, 2012-06-18 17:14

There is no option for this at this time.
For discussion: I guess a module could be developed with some JS to replace the existing cover/thumb with another thumbnail in the album.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
knorde

Joined: 2010-02-02
Posts: 64
Posted: Mon, 2012-07-02 12:04

Is there any update about this request?

Or does anyone knows how to code it by myself (the sql query).

Greets Kees.

 
rWatcher
rWatcher's picture

Joined: 2005-09-06
Posts: 722
Posted: Mon, 2012-07-02 17:00

Untested, but maybe something like this:

  $item = ORM::factory("item", $album_id)
    ->viewable()
    ->where("type", "!=", "album")
    ->where("rand_key", "<", random::percent())
    ->order_by("rand_key", "DESC");
    ->descendants(1);

$album_id would be the id# of the parent album.

 
knorde

Joined: 2010-02-02
Posts: 64
Posted: Mon, 2012-07-02 17:26

This is the original code, how i have to place the above code?

if ($child->is_album() && ($rnd = item::random_query()->where("parent_id", "=", $child->id)->find()) && $rnd->loaded()):

Greets Kees.

 
rWatcher
rWatcher's picture

Joined: 2005-09-06
Posts: 722
Posted: Mon, 2012-07-02 18:13

I would do something like:

if ($child->is_album()) {
  $rnd = ORM::factory("item", $child->id)
    ->viewable()
    ->where("type", "!=", "album")
    ->where("rand_key", "<", random::percent())
    ->order_by("rand_key", "DESC");
    ->descendants(1);
  if ($rnd->loaded()) {
    // Your code goes here.
  }
}
 
knorde

Joined: 2010-02-02
Posts: 64
Posted: Mon, 2012-07-02 19:10

It don't works.

Here is the whole code maybe it will help:

<?php defined("SYSPATH") or die("No direct script access.") ?>
<? // @todo Set hover on AlbumGrid list items for guest users ?>
<div id="g-info">
  <?= $theme->album_top() ?>
  <h1><?= html::purify($item->title) ?></h1>
  <div class="g-description"><?= nl2br(html::purify($item->description)) ?></div>
</div>

<ul id="g-album-grid" class="ui-helper-clearfix">
<? if (count($children)): ?>
  <? foreach ($children as $i => $child): ?>
    <? $item_class = "g-photo"; ?>
    <? if ($child->is_album()): ?>
      <? $item_class = "g-album"; ?>
    <? endif ?>
  <li id="g-item-id-<?= $child->id ?>" class="g-item <?= $item_class ?>">



<?= $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>
    <?= $theme->thumb_bottom($child) ?>
    <?= $theme->context_menu($child, "#g-item-id-{$child->id} .g-thumbnail") ?>
    <h2><span class="<?= $item_class ?>"></span>
      <a href="<?= $child->url() ?>"><?= html::purify($child->title) ?></a></h2>
    <ul class="g-metadata">
      <?= $theme->thumb_info($child) ?>
    </ul>
  </li>
  <? endforeach ?>
<? else: ?>
  <? if ($user->admin || access::can("add", $item)): ?>
  <? $addurl = url::site("uploader/index/$item->id") ?>
  <li><?= t("There aren't any photos here yet! <a %attrs>Add some</a>.",
            array("attrs" => html::mark_clean("href=\"$addurl\" class=\"g-dialog-link\""))) ?></li>
  <? else: ?>
  <li><?= t("There aren't any photos here yet!") ?></li>
  <? endif; ?>
<? endif; ?>
</ul>
<?= $theme->album_bottom() ?>

<?= $theme->paginator() ?>
 
knorde

Joined: 2010-02-02
Posts: 64
Posted: Sun, 2012-08-26 19:27

Is there any news about this?
There must be people who miss this option i think :)

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Fri, 2012-08-31 16:00

This seems to work but has some lag. Perhaps I can make it a bit better moving the code up a bit but this is a proof of concept first....
add

	<? if ($child->is_album()): ?>
	<? 
		$rnd = item::random_query()->where("parent_id", "=", $child->id)->find();
	?>
	<script>
	$("#g-item-id-<?= $child->id ?> img.g-thumbnail").attr("src", "<?= $rnd->thumb_url(); ?>");
	</script>
	<? endif ?>

just after
<?= $theme->thumb_top($child) ?>
in gallery3/themes/yourtheme/views/album.html.php
test and let me know.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Sat, 2012-09-01 06:59

How about the attached module?

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
shug17

Joined: 2009-01-10
Posts: 76
Posted: Sat, 2012-09-01 09:20

Dave,

excellent work - love it! Installed it and tested on one gallery so far.

Is there a setting option - so that some albums will be exempted?

Many Thanks

 
knorde

Joined: 2010-02-02
Posts: 64
Posted: Sat, 2012-09-01 12:21

Many thanks for trying :)

It works a little bit but not correctly.

See it on www.mydigitalworld.nl
Sometimes there are no thumb present but only a text with the album name.
You can try it to refresh some times :)

Second problem is that when a album has sub albums (as example the album vakantie) it don't work.
If a album has only sub albums it will be better that the thumb of the parent album will be 1 of the sub albums thumb.

When you have only pics in the album (without subs) it works ok.

This is the code:

<?php defined("SYSPATH") or die("No direct script access.") ?>
<? // @todo Set hover on AlbumGrid list items for guest users ?>
<div id="g-info">
  <?= $theme->album_top() ?>
  <h1><?= html::purify($item->title) ?></h1>
  <div class="g-description"><?= nl2br(html::purify($item->description)) ?></div>
</div>

<ul id="g-album-grid" class="ui-helper-clearfix">
<? if (count($children)): ?>
  <? foreach ($children as $i => $child): ?>
    <? $item_class = "g-photo"; ?>
    <? if ($child->is_album()): ?>
      <? $item_class = "g-album"; ?>
    <? endif ?>
  <li id="g-item-id-<?= $child->id ?>" class="g-item <?= $item_class ?>">
    <?= $theme->thumb_top($child) ?>


	<? if ($child->is_album()): ?>
	<? 
		$rnd = item::random_query()->where("parent_id", "=", $child->id)->find();
	?>
	<script>
	$("#g-item-id-<?= $child->id ?> img.g-thumbnail").attr("src", "<?= $rnd->thumb_url(); ?>");
	</script>
	<? endif ?>



    <a href="<?= $child->url() ?>">
      <? if ($child->has_thumb()): ?>
      <?= $child->thumb_img(array("class" => "g-thumbnail")) ?>
      <? endif ?>
    </a>
    <?= $theme->thumb_bottom($child) ?>
    <?= $theme->context_menu($child, "#g-item-id-{$child->id} .g-thumbnail") ?>
    <h2><span class="<?= $item_class ?>"></span>
      <a href="<?= $child->url() ?>"><?= html::purify($child->title) ?></a></h2>
    <ul class="g-metadata">
      <?= $theme->thumb_info($child) ?>
    </ul>
  </li>
  <? endforeach ?>
<? else: ?>
  <? if ($user->admin || access::can("add", $item)): ?>
  <? $addurl = url::site("uploader/index/$item->id") ?>
  <li><?= t("There aren't any photos here yet! <a %attrs>Add some</a>.",
            array("attrs" => html::mark_clean("href=\"$addurl\" class=\"g-dialog-link\""))) ?></li>
  <? else: ?>
  <li><?= t("There aren't any photos here yet!") ?></li>
  <? endif; ?>
<? endif; ?>
</ul>
<?= $theme->album_bottom() ?>

<?= $theme->paginator() ?>

Greets Kees.

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Sat, 2012-09-01 17:07
Quote:
Is there a setting option - so that some albums will be exempted?

Not yet. How do you want this setting? Number of items in an album? or album specific? How do you propose the UI to work & look like?

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Sat, 2012-09-01 17:16

Knorde,
I saw that missing item every once in a while and don't know why the $rnd variable is not used as I put it in a loop of 5 time in a do loop to set it as the item::random_query() is not 100 successful. I might have to come up with a different way.
Try the module not just the code snippet I posted.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Sat, 2012-09-01 17:19
Quote:
Second problem is that when a album has sub albums (as example the album vakantie) it don't work.
If a album has only sub albums it will be better that the thumb of the parent album will be 1 of the sub albums thumb.

So we don't want to randomize the cover if there is only sub-albums in the album?
I need a better user story to understand.
As more and more checks are added it is going to slow down so we much keep that in mind.
I don't want to randomize 1000s of item in sub-sub-subalbums as well as that is one big query and might take some time to do, slowing down the UI.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
shug17

Joined: 2009-01-10
Posts: 76
Posted: Sat, 2012-09-01 17:19

Dave,

my own personal thought is that each album can opt in or out of the random image - just like we had in G2.

So that if you have an album with 2 sub albums. one album can have the random item from an image inside it and the other album can have a fixed non random image. Then the top album will pick from the two album covers and use that as it's cover.

as for how to do it - I dunno - my coding skills are non-existent, sorry. Could the UI be in the album option menu for each album?

 
knorde

Joined: 2010-02-02
Posts: 64
Posted: Sat, 2012-09-01 17:26

Ok now i used the module only (and not the code) but i see the same effect as i described above :)

 
knorde

Joined: 2010-02-02
Posts: 64
Posted: Sat, 2012-09-01 17:38
floridave wrote:
Quote:
Second problem is that when a album has sub albums (as example the album vakantie) it don't work.
If a album has only sub albums it will be better that the thumb of the parent album will be 1 of the sub albums thumb.

So we don't want to randomize the cover if there is only sub-albums in the album?
I need a better user story to understand.
As more and more checks are added it is going to slow down so we much keep that in mind.
I don't want to randomize 1000s of item in sub-sub-subalbums as well as that is one big query and might take some time to do, slowing down the UI.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

Ok i understand but in that case the parent album has always the same thumb and will never be another one.

As example:

Parentalbum "Vacation" - Subalbum "2012" - Subalbum "Italy"
-------------------------------- Subalbum "2011"
-------------------------------- Subalbum "2010"

It will be nice if the thumb of Vacation will be random from the subs or newest one or something.
If it is a fixed one, it will always be the same after years :)

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Sat, 2012-09-01 21:01
Quote:
If it is a fixed one, it will always be the same after years

Choose your own at any time.
I will think how to make this a bit better without making the code complex to support or slow down the site.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Sat, 2012-09-01 21:03
Quote:
Ok now i used the module only (and not the code) but i see the same effect as i described above

The two albums with no highlight only have one item it it.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
knorde

Joined: 2010-02-02
Posts: 64
Posted: Sat, 2012-09-01 23:20
floridave wrote:
Quote:
Ok now i used the module only (and not the code) but i see the same effect as i described above

The two albums with no highlight only have one item it it.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

Now i have placed extra pics in (as example) Auto.

But same problem (maybe you have to refresh some times :))

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Sun, 2012-09-02 00:01

Added some code to check in $rnd is set. More upgrades to come....later

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
knorde

Joined: 2010-02-02
Posts: 64
Posted: Sun, 2012-09-02 01:38

Ok tnx, where can i download it?

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Sun, 2012-09-02 05:54

Updated to version 2.
Added an admin setting to choose sub-albums if desired. Might cause some performance issues in larger galleries.
It should not change the thumb if the random code fails.

Still thinking about the best way to eliminate some albums from randomization.

Dave

_____________________________________________
Blog & G2 || floridave - Gallery Team

 
shug17

Joined: 2009-01-10
Posts: 76
Posted: Sun, 2012-09-02 08:47

I get an error occurred while installing for version 2.

I tried to upgrade first and got the error. Then I un-installed the module deleted it with ftp and uploaded v2. installed it and still getting the error. It hasn't effected the thumbnails as far as I can see they are the ones I picked before trying this module.

Thanks

 
knorde

Joined: 2010-02-02
Posts: 64
Posted: Sun, 2012-09-02 10:27

I get an error while installing the module.

"Er is een fout opgetreden bij het installeren van de module Random album cover - highlight".

It means it will not be installed because there is an error :)

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Tue, 2012-09-04 03:53

Not sure why you got an error but have attached version 3 that now includes 2 new features:
Edit album and you will be able to disable the random highlight to that specific album.
Added an admin setting to include sub-albums in the random highlight image selection. This might be a bit of a performance hit in large albums.

Later this week I will create a codex page.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
knorde

Joined: 2010-02-02
Posts: 64
Posted: Tue, 2012-09-04 07:49

Hi Dave,

This is exactly what I wanted, perfect!
Thank you!

I only have one more little thing (but this is not something to the module).
I have changed the code in the album.html.php so the pics has the correct ration portrait or landscape.

If I use the original album.html.php the random module works fine but with the custom album.html.php it does not work correctly.
Maybe you know what I would have to change to get it working on my code?
The code is below.

<?= $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>
 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Tue, 2012-09-04 13:37
Quote:
If I use the original album.html.php the random module works fine but with the custom album.html.php it does not work correctly.

What do you mean by not working? I'm assuming that the image is distorted as different images are used?
Is the code you posted the whole album.html.php?

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
knorde

Joined: 2010-02-02
Posts: 64
Posted: Tue, 2012-09-04 14:31

I don't use other pics.
When i use the custom album.html.php the ration (portrait or landscape) isn't everytime correct.
And randomize subalbums not working then (see Vakantie).

You can test it to refresh some times :)

When i use the original album.html.php the random module works perfect only in that case i have not the right ration (portrait or landscape).

Below is the whole code from my custom album.html.php

<?php defined("SYSPATH") or die("No direct script access.") ?>
<? // @todo Set hover on AlbumGrid list items for guest users ?>
<div id="g-info">
  <?= $theme->album_top() ?>
  <h1><?= html::purify($item->title) ?></h1>
  <div class="g-description"><?= nl2br(html::purify($item->description)) ?></div>
</div>

<ul id="g-album-grid" class="ui-helper-clearfix">
<? if (count($children)): ?>
  <? foreach ($children as $i => $child): ?>
    <? $item_class = "g-photo"; ?>
    <? if ($child->is_album()): ?>
      <? $item_class = "g-album"; ?>
    <? endif ?>
  <li id="g-item-id-<?= $child->id ?>" class="g-item <?= $item_class ?>">



<?= $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>
    <?= $theme->thumb_bottom($child) ?>
    <?= $theme->context_menu($child, "#g-item-id-{$child->id} .g-thumbnail") ?>
    <h2><span class="<?= $item_class ?>"></span>
      <a href="<?= $child->url() ?>"><?= html::purify($child->title) ?></a></h2>
    <ul class="g-metadata">
      <?= $theme->thumb_info($child) ?>
    </ul>
  </li>
  <? endforeach ?>
<? else: ?>
  <? if ($user->admin || access::can("add", $item)): ?>
  <? $addurl = url::site("uploader/index/$item->id") ?>
  <li><?= t("There aren't any photos here yet! <a %attrs>Add some</a>.",
            array("attrs" => html::mark_clean("href=\"$addurl\" class=\"g-dialog-link\""))) ?></li>
  <? else: ?>
  <li><?= t("There aren't any photos here yet!") ?></li>
  <? endif; ?>
<? endif; ?>
</ul>
<?= $theme->album_bottom() ?>

<?= $theme->paginator() ?>
 
shug17

Joined: 2009-01-10
Posts: 76
Posted: Tue, 2012-09-04 16:58

Dave,

looking great - working on one install already - 3 more to go when I get time.

Thanks You so much!

Shug17

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Tue, 2012-09-04 21:13
Quote:
When i use the custom album.html.php the ration (portrait or landscape) isn't everytime correct.

Is this customization for random album highlights? You cson't need a new album.html.php to accomlish this as the module will do it for you.
Is there some special customization? If so what is the customization suppose to accomplish?
Do you need the custom file? If so why?
What theme is that so I can test with it?

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Tue, 2012-09-04 21:39

Also viwing the source of your page the Vakantie thumbnail never changes as the class to the image changes for some reason.
<img class="g-thumbnail2"
where does the 2 come from?

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Tue, 2012-09-04 21:42

Is this:

<? 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 ?>    

part of the original theme?

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Tue, 2012-09-04 21:54

Your theme or your customization need some work
notice the 2 closing </a> tags:

<? 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> 

I would suggest using the original theme code and report back your findings.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
knorde

Joined: 2010-02-02
Posts: 64
Posted: Tue, 2012-09-04 21:55

The theme is browny_wind.

For every different screen resolution i use a different css file.
In every screen resolution .css (1024x768.css and 1280x1024.css and 1360x768.css etc. etc.) i have the code:

.g-thumbnail {
  border: 1px solid #000000;
  margin-top: 3px;
  margin-bottom: 3px;
max-height: 120px;
max-width: 90px;
}

.g-thumbnail2 {
  border: 1px solid #000000;
  margin-top: 3px;
  margin-bottom: 3px;
max-height: 120px;
max-width: 160px;
}

The result is that every screen resolution has a nice site resolution.

g-thumbnail and g-thumbnail2 is portrait or landscape.

<? 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 ?>    

The above code is not a part of the original browny_wind theme.

I have made it by myself.
The code works perfect without the random module.

This is the original album.html.php

<?php defined("SYSPATH") or die("No direct script access.") ?>
<? // @todo Set hover on AlbumGrid list items for guest users ?>
<div id="g-info">
  <?= $theme->album_top() ?>
  <h1><?= html::purify($item->title) ?></h1>
  <div class="g-description"><?= nl2br(html::purify($item->description)) ?></div>
</div>

<ul id="g-album-grid" class="ui-helper-clearfix">
<? if (count($children)): ?>
  <? foreach ($children as $i => $child): ?>
    <? $item_class = "g-photo"; ?>
    <? if ($child->is_album()): ?>
      <? $item_class = "g-album"; ?>
    <? endif ?>
  <li id="g-item-id-<?= $child->id ?>" class="g-item <?= $item_class ?>">
    <?= $theme->thumb_top($child) ?>
    <a href="<?= $child->url() ?>">
      <? if ($child->has_thumb()): ?>
      <?= $child->thumb_img(array("class" => "g-thumbnail")) ?>
      <? endif ?>
    </a>
    <?= $theme->thumb_bottom($child) ?>
    <?= $theme->context_menu($child, "#g-item-id-{$child->id} .g-thumbnail") ?>
    <h2><span class="<?= $item_class ?>"></span>
      <a href="<?= $child->url() ?>"><?= html::purify($child->title) ?></a></h2>
    <ul class="g-metadata">
      <?= $theme->thumb_info($child) ?>
    </ul>
  </li>
  <? endforeach ?>
<? else: ?>
  <? if ($user->admin || access::can("add", $item)): ?>
  <? $addurl = url::site("uploader/index/$item->id") ?>
  <li><?= t("There aren't any photos here yet! <a %attrs>Add some</a>.",
            array("attrs" => html::mark_clean("href=\"$addurl\" class=\"g-dialog-link\""))) ?></li>
  <? else: ?>
  <li><?= t("There aren't any photos here yet!") ?></li>
  <? endif; ?>
<? endif; ?>
</ul>
<?= $theme->album_bottom() ?>

<?= $theme->paginator() ?>
 
knorde

Joined: 2010-02-02
Posts: 64
Posted: Tue, 2012-09-04 21:59
floridave wrote:
Your theme or your customization need some work
notice the 2 closing </a> tags:

<? 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> 

I would suggest using the original theme code and report back your findings.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

Above that is the <a> look:

    <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>

:)

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Wed, 2012-09-05 01:46
Quote:
The code works perfect without the random module.

I works just fine without your customization's as well i bet. :-)

Quote:
Above that is the <a> look:

I'm not going to debug your theme in this thread. I just saw two closing </a> tags when viewing the source.

OK for your custom theme see if this helps:

<script type="text/javascript">
  $("#g-item-id-<?= $child->id ?> img[class^=g-thumbnail]").attr("src", "<?= $rnd->thumb_url(); ?>");
  $("#g-item-id-<?= $child->id ?> img[class^=g-thumbnail]").attr("height", "<?= $rnd->thumb_height; ?>");
  $("#g-item-id-<?= $child->id ?> img[class^=g-thumbnail]").attr("width", "<?= $rnd->thumb_width; ?>");
</script>

Replace the code_thumb_top.html.php in my modules view folder with the above code.

Perhaps a better JS jquery expert can chime in if getting the selector above to work with g-thumbnail and g-thumbnail2 to work without selecting too much or too little.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
knorde

Joined: 2010-02-02
Posts: 64
Posted: Wed, 2012-09-05 07:15

Hi,

The random module works but the pics are in incorrect resolution sometimes now (portrait or landscape).
When i turn the random module off the resolution (portrait or landscape) is always ok.

I think the problem is that in the random module code i only see g-thumbnail and not g-thumbnail2.

No idea :P

<script type="text/javascript">
  $("#g-item-id-<?= $child->id ?> img[class^=g-thumbnail]").attr("src", "<?= $rnd->thumb_url(); ?>");
  $("#g-item-id-<?= $child->id ?> img[class^=g-thumbnail]").attr("height", "<?= $rnd->thumb_height; ?>");
  $("#g-item-id-<?= $child->id ?> img[class^=g-thumbnail]").attr("width", "<?= $rnd->thumb_width; ?>");
</script>
 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Wed, 2012-09-05 10:47

Your site is down now so it is hard to diagnose your theme issue.
Can you give me a clue? Seems your theme changes the size of the thumbnail and perhaps the JS code to replace the thumb has different size than the attributes it is replacing.

Anybody else have a issue? or is it just this customized theme?

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
shug17

Joined: 2009-01-10
Posts: 76
Posted: Wed, 2012-09-05 20:25

The module works really well and is so easy to use.

Huge Thanks

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Wed, 2012-09-05 22:31
Quote:
I think the problem is that in the random module code i only see g-thumbnail and not g-thumbnail2.

The jquery selector:
#g-item-id-<?= $child->id ?> img[class^=g-thumbnail] says:
Select the id of g-item-id-XXXX where XXX is the id of the album then choose the img with a class that starts with g-thumbnail

So any image in a <div> with the id of g-item-id-$child->id that has a class of g-thumbnail or g-thumbnail1 or g-thumbnail2 should be swapped.
^= is the key that basically says starts with

I hope that helps in understand how it gets swapped.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Wed, 2012-09-05 22:48

@knorde, your site is still down to diagnose.

@shug17, Glad it is working. Got some suggestions to flesh out the docs> http://codex.gallery2.org/Gallery3:Modules:random_album_highlight

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
knorde

Joined: 2010-02-02
Posts: 64
Posted: Mon, 2012-09-10 11:58
floridave wrote:
@knorde, your site is still down to diagnose.

Don't know the reasson but the error log says:

Premature end of script headers: index.php

I have nothing changed...
Hope i can fix it...

I think this is the problem, my host has upgraded the php version.
http://www.directadmin.com/forum/showthread.php?t=39820&page=1
(Gallery 3 does not work with php5.3.6 and suPHP)

EDIT
My host has not upgraded the php version.
http://kene.nl/phpinfo.php

Don't know now what to do :(

Greets Kees.

 
knorde

Joined: 2010-02-02
Posts: 64
Posted: Wed, 2012-09-12 07:41

Ok now i have re-installed the whole site.
The site is back online now (don't know what the problem is but np.

I hope you can diagnose now :)
If you need it i can give you ftp access.

Greets Kees.

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Mon, 2012-09-17 01:59

knorde,
With your custom theme and some custom JS for your page, perhaps this module is not compatible with your customization.
You are more familiar with those customization (re-sizing the thumbs) so if you have recommendations to work around those, please let me know and I can most likely accommodate them.
I'm not prepared to work on some JS/theme customization I'm not familiar with.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
knorde

Joined: 2010-02-02
Posts: 64
Posted: Sun, 2012-10-07 17:24

Finally it works now, it is difficult to say how the code is now (i had to change more files) but it works now perfect!

Many thanks!

Greets Kees.

 
chrisgaines717

Joined: 2012-10-19
Posts: 1
Posted: Fri, 2012-10-19 02:39

Hey Dave,
I was searching for an option to implement some random album covers. I installed what you suggested, and it worked great for me on my gallery.

Thanks for sharing,
Chris