src/Sulu/Bundle/MediaBundle/Controller/MediaPreviewController.php
public function deleteAction($id, Request $request)
    {
        try {
            $mediaManager = $this->getMediaManager();

            $locale = $this->getLocale($request);

            $media = $mediaManager->getById($id, $locale);
            /** @var MediaInterface $mediaEntity */
            $mediaEntity = $media->getEntity();

            if (null !== $mediaEntity->getPreviewImage()) {
                $oldPreviewImageId = $mediaEntity->getPreviewImage()->getId();

                $mediaEntity->setPreviewImage(null);

                $mediaManager->delete($oldPreviewImageId);
            }

            $view = $this->view(null, 204);
        } catch (MediaNotFoundException $e) {
            $view = $this->view($e->toArray(), 404);
        } catch (MediaException $e) {
            $view = $this->view($e->toArray(), 400);
        }

        return $this->handleView($view);
    }
public function deleteAction($id, Request $request)
    {
        try {
            $mediaManager = $this->getMediaManager();

            $locale = $this->getLocale($request);

            $media = $mediaManager->getById($id, $locale);
            /** @var MediaInterface $mediaEntity */
            $mediaEntity = $media->getEntity();

            if (null !== $mediaEntity->getPreviewImage()) {
                $oldPreviewImageId = $mediaEntity->getPreviewImage()->getId();

                $mediaEntity->setPreviewImage(null);

                $mediaManager->delete($oldPreviewImageId);
            }

            $view = $this->view(null, 204);
        } catch (MediaNotFoundException $e) {
            $view = $this->view($e->toArray(), 404);
        } catch (MediaException $e) {
            $view = $this->view($e->toArray(), 400);
        }

        return $this->handleView($view);
    }
public function deleteAction ( $ id , Request $ request ) { try { $ mediaManager = $ this -> getMediaManager ( ) ; $ locale = $ this -> getLocale ( $ request ) ; $ media = $ mediaManager -> getById ( $ id , $ locale ) ; /** @var MediaInterface $mediaEntity */ $ mediaEntity = $ media -> getEntity ( ) ; if ( null !== $ mediaEntity -> getPreviewImage ( ) ) { $ oldPreviewImageId = $ mediaEntity -> getPreviewImage ( ) -> getId ( ) ; $ mediaEntity -> setPreviewImage ( null ) ; $ mediaManager -> delete ( $ oldPreviewImageId ) ; } $ view = $ this -> view ( null , 204 ) ; } catch ( MediaNotFoundException $ e ) { $ view = $ this -> view ( $ e -> toArray ( ) , 404 ) ; } catch ( MediaException $ e ) { $ view = $ this -> view ( $ e -> toArray ( ) , 400 ) ; } return $ this -> handleView ( $ view ) ; }
Removes current preview image and sets default video thumbnail.

@Delete("media/{id}/preview")

@param $id
@param Request $request

@return \Symfony\Component\HttpFoundation\Response
Removes current preview image and sets default video thumbnail .