Inheritance: extends Illuminate\Support\Collection
 /**
  * Create all derived files for the given media.
  *
  * @param \Spatie\MediaLibrary\Media $media
  */
 public function createDerivedFiles(Media $media)
 {
     $profileCollection = ConversionCollection::createForMedia($media);
     $this->performConversions($profileCollection->getNonQueuedConversions($media->collection_name), $media);
     $queuedConversions = $profileCollection->getQueuedConversions($media->collection_name);
     if (count($queuedConversions)) {
         $this->dispatchQueuedConversions($media, $queuedConversions);
     }
 }
Esempio n. 2
0
 public function getMediaConversionNames() : array
 {
     $conversions = ConversionCollection::createForMedia($this);
     return $conversions->map(function (Conversion $conversion) {
         return $conversion->getName();
     })->toArray();
 }
 protected function deleteFilesGeneratedForDeprecatedConversions()
 {
     $this->getMediaItems()->each(function (Media $media) {
         $conversionFilePaths = ConversionCollection::createForMedia($media)->getConversionsFiles($media->collection_name);
         $path = $this->basePathGenerator->getPathForConversions($media);
         $currentFilePaths = $this->fileSystem->disk($media->disk)->files($path);
         collect($currentFilePaths)->filter(function (string $currentFilePath) use($conversionFilePaths) {
             return !$conversionFilePaths->contains(basename($currentFilePath));
         })->each(function (string $currentFilePath) use($media) {
             if (!$this->isDryRun) {
                 $this->fileSystem->disk($media->disk)->delete($currentFilePath);
             }
             $this->info("Deprecated conversion file `{$currentFilePath}` " . ($this->isDryRun ? 'found' : 'has been removed'));
         });
     });
 }