I have a Facebook-style chat on my drupal website, however the script was lacking user picture integration. I managed to get user pictures, but if the user didn't set picture and is using a default picture I'm getting a broken image and a 404 not found
in the logs. I've tried to fetch gravatar
for users without a picture set, but couldn't make it work.
/**
* This function returns the URL of the avatar of the specified user ID.
*
* @param userid the user ID of the user
* @param image if the image includes more than just a user ID, this param is passed
* in from the avatar row in the buddylist and get user details functions.
* @return the link of the user ID's profile
*/
function get_avatar($image, $user_id, $account) {
return "http://mypage.com/files/pictures/picture-" . ($user_id) . ".jpg";
if (empty($account->picture)) {
return "http://www.gravatar.com/avfatar/" . md5($image) . "?d=identicon";
}
}