diff --git a/Neos.Fusion/Classes/FusionObjects/ComponentImplementation.php b/Neos.Fusion/Classes/FusionObjects/ComponentImplementation.php
index 873128d0c2d..8d7f9da3209 100644
--- a/Neos.Fusion/Classes/FusionObjects/ComponentImplementation.php
+++ b/Neos.Fusion/Classes/FusionObjects/ComponentImplementation.php
@@ -80,8 +80,10 @@ protected function getProps(array $context): \ArrayAccess
protected function render(array $context)
{
$this->runtime->pushContextArray($context);
- $result = $this->runtime->render($this->path . '/renderer');
- $this->runtime->popContext();
- return $result;
+ try {
+ return $this->runtime->render($this->path . '/renderer');
+ } finally {
+ $this->runtime->popContext();
+ }
}
}
diff --git a/Neos.Media.Browser/Classes/Controller/AssetController.php b/Neos.Media.Browser/Classes/Controller/AssetController.php
index c17b24b671c..a4ee773a8ca 100644
--- a/Neos.Media.Browser/Classes/Controller/AssetController.php
+++ b/Neos.Media.Browser/Classes/Controller/AssetController.php
@@ -50,6 +50,7 @@
use Neos\Media\Domain\Repository\AssetRepository;
use Neos\Media\Domain\Repository\TagRepository;
use Neos\Media\Domain\Service\AssetService;
+use Neos\Media\Domain\Service\AssetVariantGenerator;
use Neos\Media\Exception\AssetServiceException;
use Neos\Media\TypeConverter\AssetInterfaceConverter;
use Neos\Neos\Controller\BackendUserTranslationTrait;
@@ -140,6 +141,12 @@ class AssetController extends ActionController
*/
protected $assetSourceService;
+ /**
+ * @Flow\Inject
+ * @var AssetVariantGenerator
+ */
+ protected $assetVariantGenerator;
+
/**
* @var AssetSourceInterface[]
*/
@@ -469,6 +476,32 @@ public function variantsAction(string $assetSourceIdentifier, string $assetProxy
}
}
+ /**
+ * Create missing variants for the given image
+ *
+ * @param string $assetSourceIdentifier
+ * @param string $assetProxyIdentifier
+ * @param string $overviewAction
+ * @throws StopActionException
+ * @throws UnsupportedRequestTypeException
+ */
+ public function createVariantsAction(string $assetSourceIdentifier, string $assetProxyIdentifier, string $overviewAction): void
+ {
+ $assetSource = $this->assetSources[$assetSourceIdentifier];
+ $assetProxyRepository = $assetSource->getAssetProxyRepository();
+
+ $assetProxy = $assetProxyRepository->getAssetProxy($assetProxyIdentifier);
+ $asset = $this->persistenceManager->getObjectByIdentifier($assetProxy->getLocalAssetIdentifier(), Asset::class);
+
+ /** @var VariantSupportInterface $originalAsset */
+ $originalAsset = ($asset instanceof AssetVariantInterface ? $asset->getOriginalAsset() : $asset);
+
+ $this->assetVariantGenerator->createVariants($originalAsset);
+ $this->assetRepository->update($originalAsset);
+
+ $this->redirect('variants', null, null, ['assetSourceIdentifier' => $assetSourceIdentifier, 'assetProxyIdentifier' => $assetProxyIdentifier, 'overviewAction' => $overviewAction]);
+ }
+
/**
* @return void
* @throws NoSuchArgumentException
diff --git a/Neos.Media.Browser/Configuration/Policy.yaml b/Neos.Media.Browser/Configuration/Policy.yaml
index 24e025b8edb..a237114296c 100644
--- a/Neos.Media.Browser/Configuration/Policy.yaml
+++ b/Neos.Media.Browser/Configuration/Policy.yaml
@@ -6,7 +6,7 @@ privilegeTargets:
'Neos.Media.Browser:ManageAssets':
label: Allowed to manage assets
- matcher: 'method(Neos\Media\Browser\Controller\(Asset|Image)Controller->(index|new|show|edit|update|initializeCreate|create|replaceAssetResource|updateAssetResource|initializeUpload|upload|tagAsset|delete|createTag|editTag|updateTag|deleteTag|addAssetToCollection|relatedNodes|variants)Action()) || method(Neos\Media\Browser\Controller\ImageVariantController->(update)Action())'
+ matcher: 'method(Neos\Media\Browser\Controller\(Asset|Image)Controller->(index|new|show|edit|update|initializeCreate|create|replaceAssetResource|updateAssetResource|initializeUpload|upload|tagAsset|delete|createTag|editTag|updateTag|deleteTag|addAssetToCollection|relatedNodes|variants|createVariants)Action()) || method(Neos\Media\Browser\Controller\ImageVariantController->(update)Action())'
'Neos.Media.Browser:AssetUsage':
label: Allowed to calculate asset usages
diff --git a/Neos.Media.Browser/Resources/Private/Templates/Asset/Variants.html b/Neos.Media.Browser/Resources/Private/Templates/Asset/Variants.html
index 0c035452335..e024a452100 100644
--- a/Neos.Media.Browser/Resources/Private/Templates/Asset/Variants.html
+++ b/Neos.Media.Browser/Resources/Private/Templates/Asset/Variants.html
@@ -24,6 +24,13 @@