You are here

public static function UserStatisticsManager::getUserPicture in Opigno statistics 3.x

Get the default user picture.

Parameters

\Drupal\user\UserInterface $user: The user to get the name.

string $image_style: The image style to render the user picture.

Return value

array The render array to display the default user picture.

1 call to UserStatisticsManager::getUserPicture()
UserController::buildUserInfo in src/Controller/UserController.php
Builds render array for a user info block.

File

src/Services/UserStatisticsManager.php, line 580

Class

UserStatisticsManager
User statistics manager service definition.

Namespace

Drupal\opigno_statistics\Services

Code

public static function getUserPicture(UserInterface $user, string $image_style = 'user_compact_image') : array {

  // Display the user image if it isn't empty.
  if (!$user
    ->get('user_picture')
    ->isEmpty()) {
    return $user
      ->get('user_picture')
      ->view([
      'label' => 'hidden',
      'type' => 'image',
      'settings' => [
        'image_style' => $image_style,
      ],
    ]);
  }

  // Display the default profile picture.
  return static::getDefaultUserPicture($user);
}