diff --git a/core/Controller/ReferenceController.php b/core/Controller/ReferenceController.php index 591d84f3e7ca5..a892de03e7945 100644 --- a/core/Controller/ReferenceController.php +++ b/core/Controller/ReferenceController.php @@ -48,18 +48,21 @@ public function __construct(string $appName, IRequest $request, IReferenceManage /** * @PublicPage * @NoCSRFRequired + * @param string $referenceId the reference cache key + * @return Response */ public function preview(string $referenceId): Response { $reference = $this->referenceManager->getReferenceByCacheKey($referenceId); - if ($reference === null) { - return new DataResponse('', Http::STATUS_NOT_FOUND); - } try { $appData = $this->appDataFactory->get('core'); $folder = $appData->getFolder('opengraph'); $file = $folder->getFile($referenceId); - $response = new DataDownloadResponse($file->getContent(), $referenceId, $reference->getImageContentType()); + $response = new DataDownloadResponse( + $file->getContent(), + $referenceId, + $reference === null ? $file->getMimeType() : $reference->getImageContentType() + ); } catch (NotFoundException|NotPermittedException $e) { $response = new DataResponse('', Http::STATUS_NOT_FOUND); }