Weird user avatar bahaviour (v8.3.1)

Permalink
Hi

My pagetype has a User built in attribute in its composer form so I can choose an author for the page.
I am getting the user and it is correctly showing the first name and last name for that user:
$uID = $c->getCollectionUserID();
if($uID) {
   $ui = UserInfo::getByID($uID);
}
if($ui) {
   $firstName = $ui->getAttribute('first_name');
   $lastName = $ui->getAttribute('last_name');
   $avatar = $ui->getUserAvatar();
   if ($ui->hasAvatar()) {
           $av = $avatar->output(80, 80, true);
   }
    else {
           $av = '<img src="'. $this->getThemePath() .'/images/no-user-avatar.png" alt="">';
             }
}


However, with the avatar, things get weird.
I have 3 users who all have avatars and this is the behaviour I get:

Super admin - Avatar displays fine at 80 x 80 pixels.
User 2 - It doesn't get the avatar and shows my generic no-user-avatar.png image
User 3 - It gets the avatar, but shows it at 300 x 300 pixels, not the 80x80 in the output function above!

Any ideas how to fix this please?

Thanks
Dave

madesimplemedia
 
jero replied on at Permalink Reply
jero
Looking at the avatar service (concrete/src/User/Avatar/AvatarService.php), which is what is used by the getAvatar function of the userinfo object, it appears you can get one of three classes returned.

Concrete\Core\User\Avatar\StandardAvatar
Concrete\Core\User\Avatar\Gravatar
Concrete\Core\User\Avatar\EmptyAvatar

If you look at the output() method of StandardAvatar it doesn't appear to support the additional parameters you're sending it. Gravatar doesn't either, it's an extension of the first, but it returns an 80px value because that size is hard coded in to it.

So my guess is that your avatars are being rendered at the exact sizes.