Skip to content

Commit

Permalink
Merge pull request #53 from bwaidelich/patch-1
Browse files Browse the repository at this point in the history
Allow variant preset usage for custom implementations
  • Loading branch information
mficzel committed Apr 27, 2022
2 parents e968089 + ab5bc39 commit 0fd7d17
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Classes/Domain/AssetImageSource.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
use Neos\Flow\Annotations as Flow;
use Neos\Flow\Mvc\ActionRequest;
use Neos\Media\Domain\Model\AssetInterface;
use Neos\Media\Domain\Model\AssetVariantInterface;
use Neos\Media\Domain\Model\ImageInterface;
use Neos\Media\Domain\Model\ImageVariant;
use Neos\Media\Domain\Model\ThumbnailConfiguration;
use Neos\Media\Domain\Model\VariantSupportInterface;
use Neos\Media\Domain\Service\AssetService;
Expand Down Expand Up @@ -78,13 +78,13 @@ public function withVariantPreset(string $presetIdentifier, string $presetVarian
$newSource = parent::withVariantPreset($presetIdentifier, $presetVariantName);

if ($newSource->targetImageVariant !== []) {
$asset = ($newSource->asset instanceof ImageVariant) ? $newSource->asset->getOriginalAsset() : $newSource->asset;
$asset = ($newSource->asset instanceof AssetVariantInterface && $newSource->asset instanceof ImageInterface) ? $newSource->asset->getOriginalAsset() : $newSource->asset;
if ($asset instanceof VariantSupportInterface) {
$assetVariant = $asset->getVariant($newSource->targetImageVariant['presetIdentifier'], $newSource->targetImageVariant['presetVariantName']);
} else {
$assetVariant = null;
}
if ($assetVariant instanceof ImageVariant) {
if ($assetVariant instanceof AssetVariantInterface && $assetVariant instanceof ImageInterface) {
$newSource->asset = $assetVariant;
$newSource->baseWidth = $assetVariant->getWidth();
$newSource->baseHeight = $assetVariant->getHeight();
Expand Down

0 comments on commit 0fd7d17

Please sign in to comment.