mirror of
https://github.com/friendica/friendica
synced 2024-11-10 03:02:54 +00:00
Merge pull request #10448 from annando/mimetype
Detect the mimetype for external resources
This commit is contained in:
commit
4308cace68
1 changed files with 11 additions and 0 deletions
|
@ -28,8 +28,10 @@ use Friendica\DI;
|
||||||
use Friendica\Model\Contact;
|
use Friendica\Model\Contact;
|
||||||
use Friendica\Model\Photo as MPhoto;
|
use Friendica\Model\Photo as MPhoto;
|
||||||
use Friendica\Model\Post;
|
use Friendica\Model\Post;
|
||||||
|
use Friendica\Model\Storage\ExternalResource;
|
||||||
use Friendica\Util\Proxy;
|
use Friendica\Util\Proxy;
|
||||||
use Friendica\Object\Image;
|
use Friendica\Object\Image;
|
||||||
|
use Friendica\Util\Images;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Photo Module
|
* Photo Module
|
||||||
|
@ -99,6 +101,15 @@ class Photo extends BaseModule
|
||||||
|
|
||||||
$stamp = microtime(true);
|
$stamp = microtime(true);
|
||||||
$imgdata = MPhoto::getImageDataForPhoto($photo);
|
$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;
|
$data = microtime(true) - $stamp;
|
||||||
|
|
||||||
if (empty($imgdata)) {
|
if (empty($imgdata)) {
|
||||||
|
|
Loading…
Reference in a new issue