avatar on the blog

Permalink 3 users found helpful
Is it possible to display users avatar on posts on the blog?

I have three users, and everyone writes your posts.
On page list I can show who posted any post
<?php   echo $author; ?>
, but how I can show his avatar?

View Replies: View Best Answer
buildingsomethingonline replied on at Permalink Best Answer Reply
You need this code...yep had this problem before :)
$username = $c->getVersionObject()->getVersionAuthorUserName();
         $ui = UserInfo::getByUserName($username);
         if ($ui->hasAvatar() == true) {
            $av = '<img src="'.BASE_URL.DIR_REL.'/files/avatars/'.$ui->getUserID().'.jpg'.'" alt="avatar" />';
            echo $av;
         } else {
            echo 'No avatar detected. LOLOLOLOLOL';
cssninja replied on at Permalink Reply
Thanks, it works! :)
agentorange replied on at Permalink Reply
I would vote this best answer again if I could- worked great!
onemhz replied on at Permalink Reply
@windhack your code work fine, but it only read userinfo nr 1 !!!

this removes this problem:
$u = new User();
$userName = $u->getUserName();
$ui = UserInfo::getByUserName($userName);
 if ($ui->hasAvatar() == true) {
 echo '<img src="'.BASE_URL.DIR_REL.'/files/avatars/'.$ui->getUserID().'.jpg'.'" alt="'.$userName.'" />';
junebird replied on at Permalink Reply
Hi There, I applied this to the page list on my home page, and it works perfectly fine when I'm logged in, but when I log out and look at the page it show this fatal error... what am I doing wrong?
Fatal error: Call to a member function hasAvatar() on a non-object in /home/smi65/public_html/websitenam.com/conc/concrete/blocks/page_list/view.php on line 26.
On line 26 it's: if ($ui->hasAvatar() == true) {
drm92 replied on at Permalink Reply
I have this exact same problem, did you fix this?
somesayinice replied on at Permalink Reply
Sorry to resurrect and old thread but I think this is a better answer. A little cleaner. Uses helpers.

$username = $c->getVersionObject()->getVersionAuthorUserName();
$ui = UserInfo::getByUserName($username);
$full_name = $ui->getAttribute('full_name');
if ($ui->hasAvatar()) {
          $avPath = Loader::helper('concrete/avatar')->getImagePath($ui); //Path to user avatar
} else {
          $avPath = Config::get('concrete.icons.user_avatar.default'); //default icon path if no avatar
<img class="avatar avatar_img" src="<?php echo $avPath; ?>" alt="'.$full_name.'"/>