public function getAvatarImage(): ?ImageMedium
    {
        $avatars = $this->get('avatar');
        if (\is_array($avatars) && $avatars) {
            $avatar = array_shift($avatars);

            $media = $this->getMedia();
            $name = $avatar['name'] ?? null;

            $image = $name ? $media[$name] : null;
            if ($image instanceof ImageMedium) {
                return $image;
            }
        }

        return null;
    }
public function getAvatarImage(): ?ImageMedium
    {
        $avatars = $this->get('avatar');
        if (\is_array($avatars) && $avatars) {
            $avatar = array_shift($avatars);

            $media = $this->getMedia();
            $name = $avatar['name'] ?? null;

            $image = $name ? $media[$name] : null;
            if ($image instanceof ImageMedium) {
                return $image;
            }
        }

        return null;
    }
public function getAvatarImage ( ) : ? ImageMedium { $ avatars = $ this -> get ( 'avatar' ) ; if ( \ is_array ( $ avatars ) && $ avatars ) { $ avatar = array_shift ( $ avatars ) ; $ media = $ this -> getMedia ( ) ; $ name = $ avatar [ 'name' ] ?? null ; $ image = $ name ? $ media [ $ name ] : null ; if ( $ image instanceof ImageMedium ) { return $ image ; } } return null ; }
Return media object for the User's avatar.

Note: if there's no local avatar image for the user, you should call getAvatarUrl() to get the external avatar URL.

@return ImageMedium|null
Return media object for the User s avatar .