Merge pull request #10448 from annando/mimetype

Detect the mimetype for external resources
pull/10449/head
Tobias Diekershoff 2021-06-30 05:59:06 +02:00 committed by GitHub
commit 4308cace68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 0 deletions

View File

@ -28,8 +28,10 @@ use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\Photo as MPhoto;
use Friendica\Model\Post;
use Friendica\Model\Storage\ExternalResource;
use Friendica\Util\Proxy;
use Friendica\Object\Image;
use Friendica\Util\Images;
/**
* Photo Module
@ -99,6 +101,15 @@ class Photo extends BaseModule
$stamp = microtime(true);
$imgdata = MPhoto::getImageDataForPhoto($photo);
// The mimetype for an external resource can only be known after it had been fetched
if ($photo['backend-class'] == ExternalResource::NAME) {
$mimetype = Images::getMimeTypeByData($imgdata);
if (!empty($mimetype)) {
$photo['type'] = $mimetype;
}
}
$data = microtime(true) - $stamp;
if (empty($imgdata)) {