Esempio n. 1
0
 /**
  * Get the original path to a media-file.
  *
  * @param string $conversionName
  *
  * @return string
  *
  * @throws \Spatie\MediaLibrary\Exceptions\UnknownConversion
  */
 public function getPath($conversionName = '')
 {
     $urlGenerator = UrlGeneratorFactory::createForMedia($this);
     if ($conversionName != '') {
         $urlGenerator->setConversion(ConversionCollectionFactory::createForMedia($this)->getByName($conversionName));
     }
     return $urlGenerator->getPath();
 }
 public function canConvert(Media $media) : bool
 {
     if (!$this->requirementsAreInstalled()) {
         return false;
     }
     if ($this->supportedExtensions()->contains(strtolower($media->extension))) {
         return true;
     }
     $urlGenerator = UrlGeneratorFactory::createForMedia($media);
     if (method_exists($urlGenerator, 'getPath') && file_exists($media->getPath()) && $this->supportedMimetypes()->contains(strtolower(File::getMimetype($media->getPath())))) {
         return true;
     }
     return false;
 }