Improved Mime Type detection

This commit is contained in:
Michael 2020-04-01 05:42:44 +00:00
parent 248a7fa48a
commit d3722c945b
9 changed files with 89 additions and 102 deletions

View file

@ -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()) {

View file

@ -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()) {