From d5db97ac22a5cb6601d77a0e33fd96b9ee1566a9 Mon Sep 17 00:00:00 2001 From: David Mellen Date: Wed, 28 Aug 2024 10:57:00 +0200 Subject: [PATCH] feat: allow localUid in asset middleware --- Classes/Middleware/AssetMiddleware.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/Classes/Middleware/AssetMiddleware.php b/Classes/Middleware/AssetMiddleware.php index 71b35ed..33a4d50 100644 --- a/Classes/Middleware/AssetMiddleware.php +++ b/Classes/Middleware/AssetMiddleware.php @@ -44,11 +44,17 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface $path = $routing->getUri()->getPath(); $queryParams = $request->getQueryParams(); $uid = $queryParams['uid'] ?? null; + $uidLocal = $queryParams['uidLocal'] ?? null; if ( $path === '/asset' && - $uid + ( + $uid || + $uidLocal + ) ) { - $resource = $this->resourceFactory->getFileReferenceObject($uid); + $resource = $uid + ? $this->resourceFactory->getFileReferenceObject($uid) + : $this->resourceFactory->getFileObject($uidLocal); $tstamp = intval($resource->getProperty('tstamp')); $lastModified = gmdate('D, d M Y H:i:s', $tstamp) . ' GMT'; @@ -75,7 +81,7 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface ) { $cropVariant = $queryParams['breakpoint'] ?? 'default'; - $crop = $resource->getProperty('crop'); + $crop = $resource->getProperty('crop') ?? ''; $cropVariantCollection = CropVariantCollection::create($crop); $cropArea = $cropVariantCollection->getCropArea($cropVariant); @@ -93,7 +99,10 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface 'width' => $queryParams['width'] ?? null, ]; - $processedResource = $this->imageService->applyProcessingInstructions($resource, $processingInstructions); + $processedResource = $this->imageService->applyProcessingInstructions( + $resource, + $processingInstructions + ); } }