function avatar_selection_get_random_image in Avatar Selection 5.2
Same name and namespace in other branches
- 5 avatar_selection.module \avatar_selection_get_random_image()
- 6 avatar_selection.module \avatar_selection_get_random_image()
- 7 avatar_selection.module \avatar_selection_get_random_image()
Select a random avatar picture for a certain user.
Parameters
$user: User object.
Return value
Return the path to the image to be shown as avatar.
1 call to avatar_selection_get_random_image()
- avatar_selection_user in ./
avatar_selection.module - Implementation of hook_user().
File
- ./
avatar_selection.module, line 269 - The Avatar Selection module allows the user to pick an avatar image from a list already loaded by an administrative user, and to the administrator to disable uploading other avatar files by the user.
Code
function avatar_selection_get_random_image($user) {
$avatars = _avatar_selection_image_list($user);
if ($avatars['total'] > 0) {
$avatar = array_rand($avatars['avatars'], 1);
if ($avatar) {
$path = file_create_path('avatar_selection');
$avatar = $path . '/' . $avatar;
return $avatar;
}
}
return ' ';
}