First support for user headers

This commit is contained in:
Michael 2022-01-08 22:43:11 +00:00
parent 2d326c8a27
commit 59358077c7
8 changed files with 196 additions and 51 deletions

View file

@ -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
*