Try to find a strategy to delete the file alternatives for $media and run it

@param MediaInterface $media
13271
public function deleteAlternatives(MediaInterface $media)
    {
        foreach ($this->strategies as $strategy) {
            if ($strategy->support($media)) {
                $strategy->deleteAlternatives($media);

                return;
            }
        }

        $this->defaultStrategy->deleteAlternatives($media);
    }
469383
private function saveFile(MediaInterface $media)
    {
        $file = $media->getFile();

        $fileInfo = new FileInfo($file);
        $type = $fileInfo->getType();

        $media->setType($type);

        if ($media->getName() === null) {
            $media->setName($fileInfo->getName());
            $media->setAlt($fileInfo->getName());
        }

        $media
            ->setMimeType($fileInfo->getMimeType())
            ->setExtension($fileInfo->getExtension())
            ;

        if (!$this->createReference($media)) {
            return false;
        }

        $key = $this->originalDir.'/'.$media->getReference();
        $this->filesystemManipulator->save($key, $file->getPathname());

        $this->setSizeWidthAndHeight($media);

        $media->setFile();

        if ($this->limit === null || $media->getType() !== $media::IMAGE) {
            return $media;
        }

        // resize if image > limit
        if ($media->getWidth() > $this->limit || $media->getHeight() > $this->limit) {
            $resize = new Resize($this, $media);
            $resize->setTargetSize($this->limit, $this->limit);
            $resize->apply();
        }

        return $media;
    }
414606
public function prepareMedia(Media $media)
    {
        if (null === $media->getUuid()) {
            $uuid = uniqid();
            $media->setUuid($uuid);
        }

        $content = $media->getContent();
        if (empty($content)) {
            return;
        }

        if (!$content instanceof File) {
            if (!is_file($content)) {
                throw new \RuntimeException('Invalid file');
            }

            $file = new File($content);
            $media->setContent($file);
        }

        $contentType = $this->mimeTypeGuesser->guess($content->getPathname());
        if ($content instanceof UploadedFile) {
            $pathInfo = pathinfo($content->getClientOriginalName());

            if (!array_key_exists('extension', $pathInfo)) {
                $pathInfo['extension'] = $this->extensionGuesser->guess($contentType);
            }

            $media->setOriginalFilename($this->slugifier->slugify($pathInfo['filename']).'.'.$pathInfo['extension']);
            $name = $media->getName();

            if (empty($name)) {
                $media->setName($media->getOriginalFilename());
            }
        }

        $media->setContentType($contentType);
        $media->setFileSize(filesize($media->getContent()));
        $media->setUrl($this->mediaPath . $this->getFilePath($media));
        $media->setLocation('local');
    }
913019
public function deleteAction($mediaId)
    {
        $em = $this->getDoctrine()->getManager();

        /* @var Media $media */
        $media = $em->getRepository('VictoireMediaBundle:Media')->getMedia($mediaId);
        $medianame = $media->getName();
        $folder = $media->getFolder();

        $em->getRepository('VictoireMediaBundle:Media')->delete($media);

        $this->congrat('Entry \''.$medianame.'\' has been deleted!');

        return new RedirectResponse($this->generateUrl('VictoireMediaBundle_folder_show', ['folderId' => $folder->getId()]));
    }
527766
public function renderMedia(MediaInterface $media, array $options = array())
    {
        /** @var DisplayMediaInterface $strategy */
        foreach ($this->strategies as $strategy) {
            if ($strategy->support($media)) {
                return $strategy->renderMedia($media, $options);
            }
        }

        return $this->defaultStrategy->renderMedia($media, $options);
    }
1091553
public function prune($media = null)
    {
        if ($media) {
            $this->addUsingAlias(MediaTableMap::COL_ID, $media->getId(), Criteria::NOT_EQUAL);
        }

        return $this;
    }
621183
public function generateAlternatives(MediaInterface $media)
    {
        $filePath = $this->tmpDir . DIRECTORY_SEPARATOR . $media->getFilesystemName();

        foreach ($this->alternativeFormats as $formatName => $format) {
            $alternativeName = $this->generateAlternative($media->getFilesystemName(), $formatName, $format);
            $media->addAlternative($formatName, $alternativeName);
        }

        if (trim($filePath, DIRECTORY_SEPARATOR) != trim($this->tmpDir, DIRECTORY_SEPARATOR)) {
            $this->fileSystem->remove(array($filePath));
        }
    }
198163
public function removeMedia(MediaInterface $media)
    {
        if ($this->medias->contains($media)) {
            $this->medias->removeElement($media);
        }
        return $this;
    }
889416
protected function deleteFile($fileName)
    {
        if (null !== $fileName && $this->mediaStorageManager->exists($fileName)) {
            $this->mediaStorageManager->deleteContent($fileName);
        }
    }
480383
public function renderMedia(MediaInterface $media, array $params = [])
    {
        switch ($media->getType()) {
            case MediaTypes::VIDEO :
                return $this->renderVideo($media, $params);
            case MediaTypes::FLASH :
                return $this->renderFlash($media, $params);
            case MediaTypes::AUDIO :
                return $this->renderAudio($media, $params);
            case MediaTypes::IMAGE :
                return $this->renderImage($media, $params);
            default:
                return $this->renderFile($media, $params);
        }
    }
889719
protected function processSomeFiles($models, $media)
    {
        foreach ($models as $model) {
            foreach ($model->getMediaFiles() as $file) {
                if (in_array($file->name, $media)) {
                    $file->reprocess();
                }
            }
        }
    }
903103
protected function setFileContents(MediaInterface $media, $contents = null)
    {
        $file = $this->getFilesystem()->get(sprintf('%s/%s', $this->generatePath($media), $media->getProviderReference()), true);
        $metadata = $this->metadata ? $this->metadata->get($media, $file->getName()) : [];

        if ($contents) {
            $file->setContent($contents, $metadata);

            return;
        }

        $binaryContent = $media->getBinaryContent();
        if ($binaryContent instanceof File) {
            $path = $binaryContent->getRealPath() ?: $binaryContent->getPathname();
            $file->setContent(file_get_contents($path), $metadata);

            return;
        }
    }
1238020
public function preSave(MediaInterface $media)
    {
        preg_match('/(?<=v(\=|\/))([-a-zA-Z0-9_]+)|(?<=youtu\.be\/)([-a-zA-Z0-9_]+)/', $media->getReference(), $matches);

        $media->setReference($matches[2]);

        if (!isset($media->old) || $media->old->getReference() !== $media->getReference()) {
            $this->updateMedadata($media);
        }
    }
66377
public function prepareMedia(Media $media)
    {
        if (null === $media->getUuid()) {
            $uuid = uniqid();
            $media->setUuid($uuid);
        }
        $content = $media->getContent();
        if (empty($content)) {
            return;
        }
        if (!$content instanceof File) {
            if (!is_file($content)) {
                throw new \RuntimeException('Invalid file');
            }
            $file = new File($content);
            $media->setContent($file);
        }
        if ($content instanceof UploadedFile) {
            $pathInfo = pathinfo($content->getClientOriginalName());
            $media->setOriginalFilename($this->urlizer->urlize($pathInfo['filename']).'.'.$pathInfo['extension']);
            $name = $media->getName();
            if (empty($name)) {
                $media->setName($media->getOriginalFilename());
            }
        }
        $media->setFileSize(filesize($media->getContent()));
        $contentType = $this->mimeTypeGuesser->guess($media->getContent()->getPathname());
        $media->setContentType($contentType);
        $relativePath = sprintf('/%s.%s', $media->getUuid(), ExtensionGuesser::getInstance()->guess($media->getContentType()));
        $media->setUrl('/uploads/media'.$relativePath);
        $media->setLocation('local');
    }
1237794
public function preUpdate(MediaInterface $media)
    {
        $this->cleanTranslations($media);
        $this->uploader->prepare($media);
    }
719624
public function saveMedia($media)
    {
        $file = $media->getFile();
        $this->mediaStorageManager->uploadFile($file->getFilename(), $file->getRealPath(), false);

        $this->objectManager->persist($media);
        $this->objectManager->flush();

        $event = new MediaEvent($media);
        $this->dispatcher->dispatch(MediaEvents::MEDIA_ADD, $event);
    }
1182287
public function renderMedia(MediaInterface $media, array $options)
    {
        $options = $this->validateOptions($options, __METHOD__);

        return $this->render(
            'OpenOrchestraMediaBundle:RenderMedia:image.html.twig',
            array(
                'media_url' => $this->getMediaFormatUrl($media, $options['format']),
                'media_alt' => $options['alt'],
                'id'        => $options['id'],
                'class'     => $options['class'],
                'style'     => $options['style'],
                'legend'    => $options['legend']
            )
        );
    }