class UserProfileImage in Content Planner 8
Class UserProfileImage.
Hierarchy
- class \Drupal\content_planner\UserProfileImage
Expanded class hierarchy of UserProfileImage
3 files declare their use of UserProfileImage
- BaseEntry.php in src/
Component/ BaseEntry.php - RecentKanbanActivities.php in modules/
content_kanban/ src/ Plugin/ DashboardBlock/ RecentKanbanActivities.php - UserBlock.php in src/
Plugin/ DashboardBlock/ UserBlock.php
File
- src/
UserProfileImage.php, line 12
Namespace
Drupal\content_plannerView source
class UserProfileImage {
/**
* Helper method that generate image url of the user.
*
* @param \Drupal\user\UserInterface $user
* User entity.
* @param string $image_style
* Image style ID.
*
* @return bool|string
* Image url or FALSE on failure.
*/
public static function generateProfileImageUrl(UserInterface $user, $image_style) {
if (($user_picture_field = $user
->get('user_picture')
->getValue()) && ($image_file_id = $user_picture_field[0]['target_id']) && ($file_entity = File::load($image_file_id)) && ($style = ImageStyle::load($image_style))) {
// Build image style url.
return $style
->buildUrl($file_entity
->getFileUri());
}
return FALSE;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
UserProfileImage:: |
public static | function | Helper method that generate image url of the user. |