Jump to:
| Project: | Avatar gallery |
| Version: | 5.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (fixed) |
Issue Summary
My generated gallery image has a lot of whitespace at the bottom of it. I think this is because, on my site, only a few users have uploaded their avatar. The size of the gallery image is based around the number of users, not the number of users with avatars. Hence the end result for me is an image with all the actual avatars at the top and a lot of whitespace at the bottom.
Looking at the code, it seems to me that maxy (the size of the gallery image) is calculated based on the number of users at the site. IMO, if the gallery is NOT configured to show all users, then the gallery image size should be based around the number of users with avatars.
Unfortunately while I can (sort of) read PHP, I can't write it, so I can't really offer a patch. But I think a possible solution could be: determine whether showall is on/off and whether there's an image to use for users without an avatar first - then build the SQL query accordingly. If we're only showing avatars for users with an avatar another 'AND' in the SQL where clause to restrict the result to users with a picture would do the trick.
Comments
#1
Hmmm, so maybe this PHP thing isn't so hard. Here's a patch that works for me (unified diff). Basically, I move the code for getting the values of
$miss_imageand$show_missto the top of the function. Then I build the SQL query accordingly, which means that if we're not showing an image for users without and avatar, an extra SQLandis added to thewhereclause and the returned set of users is limited to those with pictures. Otherwise the behaviour is identical to the old code.--- avatar_gallery.module 2007-01-09 22:18:19.000000000 -0800
+++ avatar_gallery.module 2007-04-17 20:39:23.874899000 -0700
@@ -306,9 +306,17 @@
function avatar_gallery_regenerate()
{
$order = variable_get('avatar_gallery_ordering', 'uid DESC');
+ $miss_image = variable_get('avatar_gallery_miss_image', '');
+ $show_miss = variable_get('avatar_gallery_showall', 0) && $miss_image;
+
+ $query = 'SELECT uid,name,picture FROM {users} WHERE status != 0 and uid != 0';
+ if (!$show_miss) {
+ $query .= ' and picture <> \'\'';
+ }
+ $query .= ' ORDER BY %s';
$items = array();
- $result = db_query('SELECT uid,name,picture FROM {users} WHERE status != 0 and uid != 0 ORDER BY %s', $order);
+ $result = db_query($query, $order);
while ($account = db_fetch_object($result)) {
$items[] = $account;
}
@@ -335,9 +343,6 @@
$quality = variable_get('avatar_gallery_quality', 80);
- $miss_image = variable_get('avatar_gallery_miss_image', '');
- $show_miss = variable_get('avatar_gallery_showall', 0) && $miss_image;
-
$maxx = $numcols * $hspacing + $margin * 2;
$maxy = ceil(count($items) / $numcols) * $vspacing + $margin * 2;
#2
Reverting the title.
#3
#4
I tried the patch, but I get an error on line 4
function avatar_gallery_regenerate()
Any ideas on this?
#5
Would you care to post some more details of the error you are getting? Perhaps a cut-and-paste of your shell as you apply the patch.
#6
I tried to patch from my windows machine prior to uploading. That's where I got the error. Maybe if someone could post the file in an actual patch that would help. This was the first time I tried to compile a patch.
#7
Integrated in the 5.x-1.x-dev version of May 6, 2008.
#8
Automatically closed -- issue fixed for two weeks with no activity.