You are here

class UserProfileImage in Content Planner 8

Class UserProfileImage.

Hierarchy

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_planner
View 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

Namesort descending Modifiers Type Description Overrides
UserProfileImage::generateProfileImageUrl public static function Helper method that generate image url of the user.