From d2b32a151eda05785d22bb8336fda06c6d9db7af Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 30 Jun 2021 03:47:53 +0000 Subject: [PATCH 1/2] Detect the mimetype for external resources --- src/Module/Photo.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Module/Photo.php b/src/Module/Photo.php index 84c2c7fce3..d6f58e610f 100644 --- a/src/Module/Photo.php +++ b/src/Module/Photo.php @@ -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 resources 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)) { From 39fe60744ba860340c4dd4a445123c7e27c41a78 Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 30 Jun 2021 03:49:43 +0000 Subject: [PATCH 2/2] Grammar --- src/Module/Photo.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Module/Photo.php b/src/Module/Photo.php index d6f58e610f..e5042fad4e 100644 --- a/src/Module/Photo.php +++ b/src/Module/Photo.php @@ -102,7 +102,7 @@ class Photo extends BaseModule $stamp = microtime(true); $imgdata = MPhoto::getImageDataForPhoto($photo); - // The mimetype for an external resources can only be known after it had been fetched + // 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)) {