public function OpignoUserSelectionController::getuserAvatar in Opigno Learning path 3.x
@opigno_deprecated
1 call to OpignoUserSelectionController::getuserAvatar()
- OpignoUserSelectionController::post in modules/
opigno_user_selection/ src/ Controller/ OpignoUserSelectionController.php
File
- modules/
opigno_user_selection/ src/ Controller/ OpignoUserSelectionController.php, line 83
Class
- OpignoUserSelectionController
- Returns responses for Opigno User Selection routes.
Namespace
Drupal\opigno_user_selection\ControllerCode
public function getuserAvatar($user) {
$default_image = file_create_url(drupal_get_path('module', 'opigno_user_selection') . '/assets/profile.svg');
$image_style = ImageStyle::load('thumbnail');
if (!$image_style instanceof ImageStyle) {
return $default_image;
}
/** @var \Drupal\Core\Entity\FieldableEntityInterface $user */
if (!($file = $this
->getEntityField($user, 'user_picture'))) {
return $default_image;
}
return $image_style
->buildUrl($file
->getFileUri());
}