Merge pull request #11150 from annando/user-banner

First support for user header banner image
This commit is contained in:
Philipp 2022-01-23 20:10:42 +01:00 committed by GitHub
commit 2c33a7803e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 216 additions and 60 deletions

View file

@ -310,19 +310,26 @@ class Photo extends BaseModule
}
return MPhoto::createPhotoForExternalResource($url, 0, $mimetext);
case "header":
$contact = Contact::getById($id, ['uid', 'url', 'header']);
$fields = ['uid', 'url', 'header', 'network', 'gsid'];
$contact = Contact::getById($id, $fields);
if (empty($contact)) {
return false;
}
If (($contact['uid'] != 0) && empty($contact['header'])) {
$contact = Contact::getByURL($contact['url'], false, ['header']);
$contact = Contact::getByURL($contact['url'], false, $fields);
}
if (!empty($contact['header'])) {
$url = $contact['header'];
} else {
$url = DI::baseUrl() . '/images/blank.png';
$url = Contact::getDefaultHeader($contact);
}
return MPhoto::createPhotoForExternalResource($url);
case "banner":
$photo = MPhoto::selectFirst([], ["scale" => 3, 'uid' => $id, 'photo-type' => MPhoto::USER_BANNER]);
if (!empty($photo)) {
return $photo;
}
return MPhoto::createPhotoForExternalResource(DI::baseUrl() . '/images/friendica-banner.jpg');
case "profile":
case "custom":
$scale = 4;