From 9d139f02744c7bb452be4aa7e6fff01d9f2ed436 Mon Sep 17 00:00:00 2001 From: Bernhard Rusch Date: Mon, 6 Oct 2025 11:13:15 +0200 Subject: [PATCH] Asset folder preview: do not render preview images on-the-fly if they do not exist yet - as this could potentially break the entire hosting infrastructure when dealing with huge image files (>500MB) --- src/Controller/Admin/Asset/AssetController.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/Controller/Admin/Asset/AssetController.php b/src/Controller/Admin/Asset/AssetController.php index a96b734854..d35aeefe3e 100644 --- a/src/Controller/Admin/Asset/AssetController.php +++ b/src/Controller/Admin/Asset/AssetController.php @@ -1213,12 +1213,17 @@ public function getImageThumbnailAction(Request $request): BinaryFileResponse|Js if ($request->get('treepreview')) { $thumbnailConfig = Asset\Image\Thumbnail\Config::getPreviewConfig(); - if ($request->get('origin') === 'treeNode' && !$image->getThumbnail($thumbnailConfig)->exists()) { - \Pimcore::getContainer()->get('messenger.bus.pimcore-core')->dispatch( - new AssetPreviewImageMessage($image->getId()) - ); + $exists = $image->getThumbnail($thumbnailConfig)->exists(); + if(!$exists) { + if ($request->get('origin') === 'treeNode') { + \Pimcore::getContainer()->get('messenger.bus.pimcore-core')->dispatch( + new AssetPreviewImageMessage($image->getId()) + ); - throw $this->createNotFoundException(sprintf('Tree preview thumbnail not available for asset %s', $image->getId())); + throw $this->createNotFoundException(sprintf('Tree preview thumbnail not available for asset %s', $image->getId())); + } elseif($request->get('origin') === 'folderPreview') { + return new BinaryFileResponse(PIMCORE_WEB_ROOT . '/bundles/pimcoreadmin/img/video-loading.gif'); + } } } @@ -1744,7 +1749,7 @@ public function getFolderContentPreviewAction(Request $request, 'type' => $asset->getType(), 'filename' => $asset->getFilename(), 'filenameDisplay' => htmlspecialchars($filenameDisplay ?? ''), - 'url' => $this->elementService->getThumbnailUrl($asset), + 'url' => $this->elementService->getThumbnailUrl($asset, ['origin' => 'folderPreview']), 'idPath' => $data['idPath'] = Element\Service::getIdPath($asset), ]; }