Merge pull request #10448 from annando/mimetype

Detect the mimetype for external resources
This commit is contained in:
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

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