You are here

function _gravatar_get_account_user_picture in Gravatar integration 7

Same name and namespace in other branches
  1. 6 gravatar.module \_gravatar_get_account_user_picture()

Decide which user picture should be displayed for a user account.

Parameters

$account: A user object.

Return value

A string with the path to the user's picture.

1 call to _gravatar_get_account_user_picture()
gravatar_preprocess_user_picture in ./gravatar.module
Override template_preprocess_user_picture() to display user pictures with Gravatar integration.

File

./gravatar.module, line 169
Integrates gravatar service for user pictures.

Code

function _gravatar_get_account_user_picture($account) {

  // If the user has an uploaded picture, use it first.
  if (!empty($account->picture->uri)) {
    return $account->picture->uri;
  }
  elseif (!user_access('use gravatar', $account) || user_access('disable own gravatar', $account) && isset($account->data['gravatar']) && !$account->data['gravatar']) {
    return variable_get('user_picture_default', '');
  }
  else {

    // Use email
    if (!empty($account->mail)) {
      return gravatar_get_gravatar($account->mail);
    }
    else {
      $options['force default'] = TRUE;
      if (!empty($account->hostname)) {
        $fallback = $account->hostname;
      }
      elseif (!empty($account->homepage)) {
        $fallback = $account->homepage;
      }
      else {
        $fallback = serialize($account);
      }
      return gravatar_get_gravatar($fallback, $options);
    }
  }
}