Merge pull request #10925 from annando/invalid-url
Handle invalid avatar pictures
This commit is contained in:
commit
40666d3585
1 changed files with 20 additions and 7 deletions
|
@ -36,6 +36,7 @@ use Friendica\Network\HTTPException;
|
|||
use Friendica\Object\Image;
|
||||
use Friendica\Util\Images;
|
||||
use Friendica\Util\Network;
|
||||
use Friendica\Util\ParseUrl;
|
||||
use Friendica\Util\Proxy;
|
||||
|
||||
/**
|
||||
|
@ -284,14 +285,26 @@ class Photo extends BaseModule
|
|||
$url = $contact['avatar'];
|
||||
} elseif (!empty($contact['avatar'])) {
|
||||
$url = $contact['avatar'];
|
||||
} elseif ($customsize <= Proxy::PIXEL_MICRO) {
|
||||
}
|
||||
$mimetext = '';
|
||||
if (!empty($url)) {
|
||||
$mime = ParseUrl::getContentType($url);
|
||||
if (empty($mime) || ($mime[0] != 'image')) {
|
||||
$url = '';
|
||||
} else {
|
||||
$mimetext = $mime[0] . '/' . $mime[1];
|
||||
}
|
||||
}
|
||||
if (empty($url)) {
|
||||
if ($customsize <= Proxy::PIXEL_MICRO) {
|
||||
$url = Contact::getDefaultAvatar($contact, Proxy::SIZE_MICRO);
|
||||
} elseif ($customsize <= Proxy::PIXEL_THUMB) {
|
||||
$url = Contact::getDefaultAvatar($contact, Proxy::SIZE_THUMB);
|
||||
} else {
|
||||
$url = Contact::getDefaultAvatar($contact, Proxy::SIZE_SMALL);
|
||||
}
|
||||
return MPhoto::createPhotoForExternalResource($url);
|
||||
}
|
||||
return MPhoto::createPhotoForExternalResource($url, 0, $mimetext);
|
||||
case "header":
|
||||
$contact = Contact::getById($id, ['uid', 'url', 'header']);
|
||||
if (empty($contact)) {
|
||||
|
|
Loading…
Reference in a new issue