Generates the default front url.

@param MediaInterface $media
@return string
171450
public function generateFrontUrl(MediaInterface $media)
    {
        $path = null;

        if ($media->getType() === MediaTypes::IMAGE) {
            $path = $this->cacheManager->getBrowserPath($media->getPath(), 'media_front');
        } elseif (in_array($media->getType(), [MediaTypes::VIDEO, MediaTypes::AUDIO, MediaTypes::FLASH])) {
            $path = $this->urlGenerator->generate('ekyna_media_player', ['key' => $media->getPath()], true);
        } else {
            $path = $this->urlGenerator->generate('ekyna_media_download', ['key' => $media->getPath()], true);
        }

        return $path;
    }
715031
public function iconUrl($image, $size = 16)
    {
        if (!$image) {
            return '';
        }

        $parts = explode(';', $image);
        $fileId = $parts[0];

        $src = $this->router->generate('frontendmedia_icon', ['fileId' => $fileId, 'size' => $size], UrlGeneratorInterface::ABSOLUTE_URL);

        return $src;
    }
909101
public function getImageUrlAttribute()
    {
        if ($this->exists) {
            $image = $this->image();

            if ($image) {
                return $image->url;
            }

            return config('media.image.default');
        }

        return config('media.image.default');
    }
1074782
private function getFileFolderPath(Media $media)
    {
        return substr($this->getFilePath($media), 0, strrpos($this->getFilePath($media), $media->getOriginalFilename()));
    }
234769
public function sourceUrl($media)
    {
        return new \Twig_Markup(
            $this->pool->getProvider($media->getProvider())->getUrl($media),
            'utf8'
        );
    }
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;
    }
376757
public function getUrl(ContentInterface $content, $originUrl = true)
    {
        if (!$info = $content->getPathInfo()) {
            return;
        }
        $router = $this->getRouter();

        try {
            $parameters = $info['__defaults'];
            foreach ($info as $key => $value) {
                if (strpos($key, '_') === 0) {
                    continue;
                }
                $parameters[$key] = $value;
            }
            if ($originUrl) {
                $parameters[UrlGenerator::GENERATE_NORMAL_ROUTE] = true;
            }

            return $router->generate($info['_route'], $parameters);
        } catch (\Exception $e) {
            return $e->getMessage();
        }
    }
565538
public function displayMediaForWysiwyg(MediaInterface $media, $format = '', $alt = '', $legend = '')
    {
        /** @var DisplayMediaInterface $strategy */
        foreach ($this->strategies as $strategy) {
            if ($strategy->support($media)) {
                return $strategy->displayMediaForWysiwyg($media, $format, $alt, $legend);
            }
        }

        return $this->defaultStrategy->displayMediaForWysiwyg($media, $format, $alt, $legend);
    }
996305
public function imagePath($image)
    {
        if (!$image) {
            return '';
        }

        $parts = explode(';', $image);
        $fileId = $parts[0];

        // deliver original file
        $src = $this->router->generate('frontendmedia_inline', ['fileId' => $fileId], UrlGeneratorInterface::ABSOLUTE_PATH);

        return $src;
    }
883933
public function getImageUrl($type = ''): string
    {
        if ($this->getMedia()->isEmpty()) {
            return asset('assets/back/img/other.png');
        }
        $extension = $this->getExtensionType();
        if ($extension === 'image') {
            return $this->getFileUrl($type);
        } elseif ($extension) {
            return asset('assets/back/img/'.$extension.'.png');
        }

        return asset('assets/back/img/other.png');
    }
111345
public function getUrl(MediaInterface $media, $alias = null)
    {
        return $this->filesystemManipulator->url($this->getAliasAndKey($media, $alias));
    }
390715
public function getMediaType(MediaInterface $media) {
        foreach ($this->strategies as $strategy) {
            if ($strategy->support($media)) {
                return $strategy->getMediaType();
            }
        }

        return $this->defaultStrategy->getMediaType();
    }
365082
public function renderMedia(MediaInterface $media, array $options = array())
    {
        $defaultOptions = $this->container->getParameter('thrace_media.jwplayer.options');
        $configs = array(
            'key' => $defaultOptions['key'],
            'html5player' => $defaultOptions['html5player'],
            'flashplayer' => $defaultOptions['flashplayer'],
            'type' => $media->getType(),
            'id' => uniqid('thrace_media', true),
            'file' => $this->container->get('router')->generate('thrace_media_render', array(
                'name' => $media->getMediaPath(),
                'hash' => $media->getHash()
            ), true)
        );
        
        $configs = array_replace_recursive($configs, $options);
        
        return $this->container->get('templating')
            ->render('ThraceMediaBundle:Media:media.html.twig',
                array('media' => $media, 'configs' => $configs)
            )
        ;
    }
1198871
protected function generateBinaryFromRequest(MediaInterface $media)
    {
        if (!$media->getContentType()) {
            throw new \RuntimeException(
                'You must provide the content type value for your media before setting the binary content'
            );
        }

        $request = $media->getBinaryContent();

        if (!$request instanceof Request) {
            throw new \RuntimeException('Expected Request in binary content');
        }

        $content = $request->getContent();

        // create unique id for media reference
        $guesser = ExtensionGuesser::getInstance();
        $extension = $guesser->guess($media->getContentType());

        if (!$extension) {
            throw new \RuntimeException(
                sprintf('Unable to guess extension for content type %s', $media->getContentType())
            );
        }

        $handle = tmpfile();
        fwrite($handle, $content);
        $file = new ApiMediaFile($handle);
        $file->setExtension($extension);
        $file->setMimetype($media->getContentType());

        $media->setBinaryContent($file);
    }
643349
public function getHtml(MediaInterface $media, $alias = null)
    {
        if ($media->getType() == $media::IMAGE) {
            $template = 'ApoutchikaMediaBundle:Render:image.html.twig';
        } elseif ($media->getType() == $media::VIDEO) {
            $template = 'ApoutchikaMediaBundle:Render:video.html.twig';
        } elseif ($media->getType() == $media::AUDIO) {
            $template = 'ApoutchikaMediaBundle:Render:audio.html.twig';
        } else {
            $template = 'ApoutchikaMediaBundle:Render:other.html.twig';
        }

        return $this->container->get('templating')->render($template, array(
            'media' => $media,
            'alias' => $alias,
            'url' => $this->getAbsoluteUrl($media, $alias),
        ));
    }
411994
public function getMediaUrl($mediaType)
    {
        $url = $this->body;

        if (is_array($this->body) && isset($this->body['attachment']['payload']['url']) && is_string($this->body['attachment']['payload']['url'])) {
            $url = $this->body['attachment']['payload']['url'];
        }

        $url = str_replace($mediaType . ':', '', $url);

        return $url;
    }
685037
public function getOriginalFile(Media $media)
    {
        return $this->fileSystem->get($this->getFilePath($media), true);
    }