コード例 #1
0
 /**
  * @param \Sonata\MediaBundle\Model\MediaInterface $media
  *
  * @return string the file extension for the $media, or the $defaultExtension if not available
  */
 protected function getExtension(MediaInterface $media)
 {
     $ext = $media->getExtension();
     if (!is_string($ext) || strlen($ext) < 3) {
         $ext = $this->defaultFormat;
     }
     return $ext;
 }
コード例 #2
0
 public function generatePublicThumbUrl(MediaInterface $media, $format)
 {
     $extension = $media->getExtension();
     if (!isset($params['format']) || !$params['format']) {
         $params['format'] = self::DEFAULT_THUMB_FORMAT;
     }
     return preg_replace('/' . $extension . '$/i', $params['format'], $this->generatePublicUrl($media, $format));
 }
コード例 #3
0
 /**
  * @param \Sonata\MediaBundle\Model\MediaInterface $media
  *
  * @return string the file extension for the $media, or the $defaultExtension if not available
  */
 protected function getExtension(MediaInterface $media)
 {
     $ext = $media->getExtension();
     if (!is_string($ext) || strlen($ext) < 2) {
         $ext = "mp4";
     }
     return $ext;
 }