From 01cefbd6d698e97d0c86efc33f6fbd54509528e3 Mon Sep 17 00:00:00 2001 From: Julien Veyssier Date: Wed, 22 Feb 2023 12:39:26 +0100 Subject: [PATCH] [reference preview] fix getting null mimetype if the cached reference lacks an image content type Signed-off-by: Julien Veyssier --- core/Controller/ReferenceController.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/Controller/ReferenceController.php b/core/Controller/ReferenceController.php index a892de03e79..ae6aeeaa6cc 100644 --- a/core/Controller/ReferenceController.php +++ b/core/Controller/ReferenceController.php @@ -58,10 +58,13 @@ class ReferenceController extends Controller { $appData = $this->appDataFactory->get('core'); $folder = $appData->getFolder('opengraph'); $file = $folder->getFile($referenceId); + $contentType = $reference === null || $reference->getImageContentType() === null + ? $file->getMimeType() + : $reference->getImageContentType(); $response = new DataDownloadResponse( $file->getContent(), $referenceId, - $reference === null ? $file->getMimeType() : $reference->getImageContentType() + $contentType ); } catch (NotFoundException|NotPermittedException $e) { $response = new DataResponse('', Http::STATUS_NOT_FOUND); -- 2.39.5