Skip to content

Commit

Permalink
Merge pull request #181 from humhub/enh/profile-image-banner
Browse files Browse the repository at this point in the history
Add user profile image/banner
  • Loading branch information
luke- authored Sep 23, 2024
2 parents 6204832 + 3cc32cd commit 3aa4498
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 13 deletions.
21 changes: 17 additions & 4 deletions definitions/UserDefinitions.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use humhub\modules\user\models\Group;
use humhub\modules\user\models\Session;
use humhub\modules\user\models\User;
use yii\helpers\ArrayHelper;
use yii\helpers\Url;

/**
Expand All @@ -41,14 +42,26 @@ public static function getUser(User $user)
'display_name' => $user->displayName,
'url' => Url::to(['/', 'container' => $user], true),
'account' => static::getAccount($user),
'profile' => static::getProfile($user->profile),
'profile' => static::getProfile($user),
];
}

public static function getProfile(Profile $profile)
public static function getProfile(User $user)
{
$attributes = $profile->attributes;
unset($attributes['user_id']);
$attributes = $user->profile->attributes;
ArrayHelper::remove($attributes, 'user_id');

ArrayHelper::setValue(
$attributes,
'image_url',
Url::to($user->profileImage->getUrl(), true),
);
ArrayHelper::setValue(
$attributes,
'banner_url',
Url::to($user->profileBannerImage->getUrl(), true),
);

return $attributes;
}

Expand Down
1 change: 1 addition & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Changelog

0.10.4 (Unreleased)
---------------------------
- Enh #181: Added user profile `image_url` and `banner_url`
- Enh #179: Added new `resend` and `cancel` endpoints for user invite

0.10.3 (September 13, 2024)
Expand Down
4 changes: 2 additions & 2 deletions docs/html/auth.html

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions docs/html/user.html

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions docs/swagger/user.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,10 @@ definitions:
type: string
url_twitter:
type: string
image_url:
type: string
banner_url:
type: string
xml:
name: Profile

Expand Down

0 comments on commit 3aa4498

Please sign in to comment.