mirror of
https://github.com/friendica/friendica
synced 2025-04-26 22:30:18 +00:00
Improved Mime Type detection
This commit is contained in:
parent
248a7fa48a
commit
d3722c945b
9 changed files with 89 additions and 102 deletions
|
@ -432,9 +432,7 @@ class Photo
|
|||
return false;
|
||||
}
|
||||
|
||||
if (empty($type)) {
|
||||
$type = Images::guessType($image_url, true);
|
||||
}
|
||||
$type = Images::getMimeTypeByData($img_str, $image_url, $type);
|
||||
|
||||
$Image = new Image($img_str, $type);
|
||||
if ($Image->isValid()) {
|
||||
|
|
|
@ -839,9 +839,16 @@ class User
|
|||
$photo_failure = false;
|
||||
|
||||
$filename = basename($photo);
|
||||
$img_str = Network::fetchUrl($photo, true);
|
||||
// guess mimetype from headers or filename
|
||||
$type = Images::guessType($photo, true);
|
||||
$curlResult = Network::curl($photo, true);
|
||||
if ($curlResult->isSuccess()) {
|
||||
$img_str = $curlResult->getBody();
|
||||
$type = $curlResult->getContentType();
|
||||
} else {
|
||||
$img_str = '';
|
||||
$type = '';
|
||||
}
|
||||
|
||||
$type = Images::getMimeTypeByData($img_str, $photo, $type);
|
||||
|
||||
$Image = new Image($img_str, $type);
|
||||
if ($Image->isValid()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue