Neos.Media.Browser/Classes/Controller/AssetController.php
public function updateAssetResourceAction(AssetInterface $asset, PersistentResource $resource, array $options = []): void
    {
        $sourceMediaType = MediaTypes::parseMediaType($asset->getMediaType());
        $replacementMediaType = MediaTypes::parseMediaType($resource->getMediaType());

        // Prevent replacement of image, audio and video by a different mimetype because of possible rendering issues.
        if ($sourceMediaType['type'] !== $replacementMediaType['type'] && in_array($sourceMediaType['type'], ['image', 'audio', 'video'])) {
            $this->addFlashMessage(
                'resourceCanOnlyBeReplacedBySimilarResource',
                '',
                Message::SEVERITY_WARNING,
                [$sourceMediaType['type'], $resource->getMediaType()],
                1462308179
            );
            $this->redirect('index');
        }

        try {
            $this->assetService->replaceAssetResource($asset, $resource, $options);
        } catch (\Exception $exception) {
            $this->addFlashMessage('couldNotReplaceAsset', '', Message::SEVERITY_OK, [], 1463472606);
            $this->forwardToReferringRequest();
            return;
        }

        $assetLabel = (method_exists($asset, 'getLabel') ? $asset->getLabel() : $resource->getFilename());
        $this->addFlashMessage('assetHasBeenReplaced', '', Message::SEVERITY_OK, [htmlspecialchars($assetLabel)]);
        $this->redirect('index');
    }
public function updateAssetResourceAction(AssetInterface $asset, PersistentResource $resource, array $options = []): void
    {
        $sourceMediaType = MediaTypes::parseMediaType($asset->getMediaType());
        $replacementMediaType = MediaTypes::parseMediaType($resource->getMediaType());

        // Prevent replacement of image, audio and video by a different mimetype because of possible rendering issues.
        if ($sourceMediaType['type'] !== $replacementMediaType['type'] && in_array($sourceMediaType['type'], ['image', 'audio', 'video'])) {
            $this->addFlashMessage(
                'resourceCanOnlyBeReplacedBySimilarResource',
                '',
                Message::SEVERITY_WARNING,
                [$sourceMediaType['type'], $resource->getMediaType()],
                1462308179
            );
            $this->redirect('index');
        }

        try {
            $this->assetService->replaceAssetResource($asset, $resource, $options);
        } catch (\Exception $exception) {
            $this->addFlashMessage('couldNotReplaceAsset', '', Message::SEVERITY_OK, [], 1463472606);
            $this->forwardToReferringRequest();
            return;
        }

        $assetLabel = (method_exists($asset, 'getLabel') ? $asset->getLabel() : $resource->getFilename());
        $this->addFlashMessage('assetHasBeenReplaced', '', Message::SEVERITY_OK, [htmlspecialchars($assetLabel)]);
        $this->redirect('index');
    }
public function updateAssetResourceAction ( AssetInterface $ asset , PersistentResource $ resource , array $ options = [ ] ) : void { $ sourceMediaType = MediaTypes :: parseMediaType ( $ asset -> getMediaType ( ) ) ; $ replacementMediaType = MediaTypes :: parseMediaType ( $ resource -> getMediaType ( ) ) ; // Prevent replacement of image, audio and video by a different mimetype because of possible rendering issues. if ( $ sourceMediaType [ 'type' ] !== $ replacementMediaType [ 'type' ] && in_array ( $ sourceMediaType [ 'type' ] , [ 'image' , 'audio' , 'video' ] ) ) { $ this -> addFlashMessage ( 'resourceCanOnlyBeReplacedBySimilarResource' , '' , Message :: SEVERITY_WARNING , [ $ sourceMediaType [ 'type' ] , $ resource -> getMediaType ( ) ] , 1462308179 ) ; $ this -> redirect ( 'index' ) ; } try { $ this -> assetService -> replaceAssetResource ( $ asset , $ resource , $ options ) ; } catch ( \ Exception $ exception ) { $ this -> addFlashMessage ( 'couldNotReplaceAsset' , '' , Message :: SEVERITY_OK , [ ] , 1463472606 ) ; $ this -> forwardToReferringRequest ( ) ; return ; } $ assetLabel = ( method_exists ( $ asset , 'getLabel' ) ? $ asset -> getLabel ( ) : $ resource -> getFilename ( ) ) ; $ this -> addFlashMessage ( 'assetHasBeenReplaced' , '' , Message :: SEVERITY_OK , [ htmlspecialchars ( $ assetLabel ) ] ) ; $ this -> redirect ( 'index' ) ; }
Update the resource on an asset.

@param AssetInterface $asset
@param PersistentResource $resource
@param array $options
@return void
@throws StopActionException
@throws ForwardException
Update the resource on an asset .