Posted by Pelli on December 22, 2012 at 9:42am
Hi,
I trying to do a page that show a list of users registered in my page. I would like to display the user picture/avatar. I use this code:
$userRec = db_query("SELECT name, picture FROM {users} WHERE uid = :uid", array(':uid'=>$uid));
but how can I display the picture/avata $userRec->picture?
Sorry for my English.
Thanks.
Comments
Why not use views to make the
Why not use views to make the page?
Because this part of the page
Because this part of the page should have a very specific functionality with access to various databases (not Drupal DB). That's why I preferred to make a separate module using php.
Try this
<?php$account = user_load($uid);
if (!empty($account->picture)) {
$output = theme('image_style', array('path' => $account->picture->uri, 'style_name' => 'thumbnail'));
} else {
$output = theme('image_style', array('path' => variable_get('user_picture_default', ''), 'style_name' => 'thumbnail'));
}
?>