Show user image/avatar in custom block?

Permalink 1 user found helpful
I would like to show the image/avatar attached to user x.

I have a custom block showing a list of members and their attributes.

Checking for images/avatar with $ui->hasAvatar() return true. But how do I get the image.

I think outputUserAvatar() is the trick, but how do I use this function?

Kind regards, Jens Griebel

griebel
 
griebel replied on at Permalink Reply
griebel
$ui = UserInfo::getByID($userid);
$ih = Loader::helper('image'); 
$av = Loader::helper('concrete/avatar'); 
if ($ui->hasAvatar()) {
    $avatarImgPath = $av->getImagePath( $ui, false );
    $mw = ($maxWidth) ? $maxWidth : '60';
    $mh = ($maxHeight) ? $maxHeight : '80';  
    if( substr($avatarImgPath,0,strlen(DIR_REL))==DIR_REL ) $avatarImgPath=substr($avatarImgPath,strlen(DIR_REL));
    $thumb = $ih->getThumbnail( DIR_BASE.$avatarImgPath, $mw, $mh); 
   if($thumb->src){ 
            ob_start();
       $ih->outputThumbnail(DIR_BASE.$avatarImgPath, $mw, $mh); 
       $avatarHTML=ob_get_contents();
            ob_end_clean();
   }else{
Fernandos replied on at Permalink Reply
Fernandos
thx^
onemhz replied on at Permalink Reply
onemhz
this code above not work for me :/

I found this works fine
http://www.concrete5.org/community/forums/customizing_c5/avatar-in-...
cannonf700 replied on at Permalink Reply
cannonf700
I'm trying to output the author's Avatar as part of the blog_entry page. On the front side it works handy dandy but if I open the blog_entry page under Page Defaults to setup the defaults for the page then this code returns an error:
Fatal error: Call to a member function hasAvatar() on a non-object in /home/website/public_html/website/packages/cannonf700_corporate_blog/themes/corporate_blog/blog_entry.php on line 21


do you know of a solution to this? maybe this code is outdated now that we're on 5.5.2

Thanks,
R4YM3 replied on at Permalink Reply
R4YM3
Hey, did you found a solution? Thanks in advance.
R4YM3 replied on at Permalink Reply
R4YM3