Exemplo n.º 1
0
 /**
  * Determine the path for a file version thumbnail based on the storage location
  *
  * @param \Concrete\Core\File\Version $file_version
  * @param \Concrete\Core\File\Image\Thumbnail\Type\Version $thumbnail
  * @param \Concrete\Core\File\StorageLocation\StorageLocation $storage
  * @param \Concrete\Core\File\StorageLocation\Configuration\ConfigurationInterface $configuration
  * @return string
  */
 protected function determinePath(Version $file_version, ThumbnailVersion $thumbnail, StorageLocation $storage, ConfigurationInterface $configuration)
 {
     $fss = $storage->getFileSystemObject();
     $path = $thumbnail->getFilePath($file_version);
     if ($fss->has($path)) {
         if ($configuration instanceof DeferredConfigurationInterface) {
             return $path;
         }
         return $configuration->getPublicURLToFile($path);
     }
     return $this->getDefaultPath($file_version, $thumbnail, $storage, $configuration);
 }
Exemplo n.º 2
0
 /**
  * When given a thumbnail type versin object and a full path to a file on the server
  * the file is imported into the system as is as the thumbnail.
  * @param ThumbnailTypeVersion $version
  * @param $path
  */
 public function importThumbnail(\Concrete\Core\File\Image\Thumbnail\Type\Version $version, $path)
 {
     $thumbnailPath = $version->getFilePath($this);
     $filesystem = $this->getFile()->getFileStorageLocationObject()->getFileSystemObject();
     if ($filesystem->has($thumbnailPath)) {
         $filesystem->delete($thumbnailPath);
     }
     $filesystem->write($thumbnailPath, file_get_contents($path), array('visibility' => AdapterInterface::VISIBILITY_PUBLIC, 'mimetype' => 'image/jpeg'));
     if ($version->getHandle() == \Config::get('concrete.icons.file_manager_listing.handle')) {
         $this->fvHasListingThumbnail = true;
     }
     if ($version->getHandle() == \Config::get('concrete.icons.file_manager_detail.handle')) {
         $this->fvHasDetailThumbnail = true;
     }
     $this->save();
 }
Exemplo n.º 3
0
 public function getThumbnailURL($type)
 {
     if (!$type instanceof ThumbnailTypeVersion) {
         $type = ThumbnailTypeVersion::getByHandle($type);
     }
     $fsl = $this->getFile()->getFileStorageLocationObject();
     if ($fsl) {
         $configuration = $fsl->getConfigurationObject();
         $fss = $fsl->getFileSystemObject();
         $path = $type->getFilePath($this);
         if ($fss->has($path)) {
             return $configuration->getPublicURLToFile($path);
         } else {
             return $this->getURL();
         }
     }
 }