protected function Storage::getUserPicture in OAuth2 Server 7
Get the user's picture to return as an OpenID Connect claim.
Parameters
object $account: The user account object.
Return value
string|NULL An absolute URL to the user picture, or NULL if none is found.
1 call to Storage::getUserPicture()
- Storage::getUserClaims in lib/
Drupal/ oauth2_server/ Storage.php
File
- lib/
Drupal/ oauth2_server/ Storage.php, line 495
Class
- Storage
- Provides Drupal storage (through the underlying Entity API) for the library.
Namespace
Drupal\oauth2_serverCode
protected function getUserPicture($account) {
if (!variable_get('user_pictures', 0)) {
return NULL;
}
// This uses logic from template_preprocess_user_picture().
if (!empty($account->picture)) {
if (is_numeric($account->picture)) {
$account->picture = file_load($account->picture);
}
if (!empty($account->picture->uri)) {
$picture_path = $account->picture->uri;
}
}
else {
$picture_path = variable_get('user_picture_default', NULL);
}
if (empty($picture_path)) {
return NULL;
}
if (module_exists('image') && file_valid_uri($picture_path) && ($style = variable_get('user_picture_style', ''))) {
$picture_url = image_style_url($style, $picture_path);
}
else {
$picture_url = url(file_create_url($picture_path), array(
'absolute' => TRUE,
));
}
return $picture_url;
}