Member
Member
ulfben   2008-04-03, 11:53
#1

I upgraded to 1.1.5 this weekend and noticed how the album thumbnails were constantly changing on every visit - selected on random. With a gallery like mine (~300 albums, >3700 pics) this renders the cache useless, and causes tremendous overhead for the server. The site took several seconds to load every time. :/

My preference is to select the first image from the newest directory; thus updating a gallery thumb only when content has been added (unless I've manually selected a thumb for it). It gives a useful visual clue for visitors and scales a lot better.

The change is simple: open class-album.php and look for the function getAlbumThumbImage(). Disable lines 614 (shuffle($thumbs)) and 625 (shuffle($subalbums)) to do away with random selection, and then change array_pop for array_shift to select the front-most image of the new album.

Member
Member
sbillard   2008-04-03, 17:28
#2

Actually, the change is rather more simple. Go to the album edit page and select the thumbnail you want to use. Since you want the first image, it will be at the top of the drop-down list.

Member
Member
ulfben   2008-04-03, 18:39
#3

Manually choosing a thumbnail for every directory I ever upload ([i]and[/i] already have uploaded) would get tedious [i]fast[/i].

Member
Member
sbillard   2008-04-03, 23:55
#4

Suit your self. Note, however, that if you change your sort orders you will change your thumbnail. If you want a an album to have a specific thumbnail you need to set it in admin. Otherwise you get one that is arbitrarily selected, either randomly or otherwise.

Member
Member
ulfben   2008-09-12, 17:40
#5

Updating to Zenphoto 1.2 I noticed a change in the default behaviour. ZP Core will now use array_shift (newest image of the album), and only shuffle if no thumbnail has been manually set.

This doesn't help us that've got hundreds of galleries since before the change, but it does make the hack a lot easier. Instead of what I outlined in the first post, simply change line 655:
$shuffle = $thumb != '1';
to:
$shuffle = false;

Member
Member
sbillard   2008-09-13, 00:07
#6

With the new change you can use a sql query to set all your album thumbs to '1' and be done with it. That is fairly easy even with thousands of albums.

Member
Member
ulfben   2008-09-13, 09:51
#7

Indeed. Should've thought of that. XD

Member
Member
ulfben   2008-12-26, 17:35
#8

Just updated from trunk and had to resolve this issue once and for all. Here's the query to use if anyone needs it:

UPDATE 'albums' SET 'thumb' = 1 WHERE 'thumb' IS NULL;

and for good measure (if you've got a few empty lines like I did):

UPDATE 'albums' SET 'thumb' = 1 WHERE 'thumb' = '';

  
Powered By MyBB, © 2002-2026 MyBB Group.
Made with by Curves UI.