mirror of
https://github.com/friendica/friendica
synced 2025-04-25 18:30:11 +00:00
First support for user headers
This commit is contained in:
parent
2d326c8a27
commit
59358077c7
8 changed files with 196 additions and 51 deletions
|
@ -865,6 +865,36 @@ class User
|
|||
return $url . $user['nickname'] . image_type_to_extension($imagetype) . ($updated ? '?ts=' . strtotime($updated) : '');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get banner link for given user
|
||||
*
|
||||
* @param array $user
|
||||
* @return string banner link
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function getBannerUrl(array $user):string
|
||||
{
|
||||
if (empty($user['nickname'])) {
|
||||
DI::logger()->warning('Missing user nickname key', ['trace' => System::callstack(20)]);
|
||||
}
|
||||
|
||||
$url = DI::baseUrl() . '/photo/banner/';
|
||||
|
||||
$updated = '';
|
||||
$imagetype = IMAGETYPE_JPEG;
|
||||
|
||||
$photo = Photo::selectFirst(['type', 'created', 'edited', 'updated'], ["scale" => 3, 'uid' => $user['uid'], 'photo-type' => Photo::USER_BANNER]);
|
||||
if (!empty($photo)) {
|
||||
$updated = max($photo['created'], $photo['edited'], $photo['updated']);
|
||||
|
||||
if (in_array($photo['type'], ['image/png', 'image/gif'])) {
|
||||
$imagetype = IMAGETYPE_PNG;
|
||||
}
|
||||
}
|
||||
|
||||
return $url . $user['nickname'] . image_type_to_extension($imagetype) . ($updated ? '?ts=' . strtotime($updated) : '');
|
||||
}
|
||||
|
||||
/**
|
||||
* Catch-all user creation function
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue