diff --git a/src/Commands/GenerateMediaConversionsCommand.php b/src/Commands/GenerateMediaConversionsCommand.php index 2f0f274..88fd47d 100644 --- a/src/Commands/GenerateMediaConversionsCommand.php +++ b/src/Commands/GenerateMediaConversionsCommand.php @@ -51,33 +51,40 @@ public function handle(): int foreach ($items as $media) { /** @var Media $media */ - $media->dispatchConversions( - queued: true, - filter: function ($definition) use ($media, $force, $immediate, $conversions) { - - if ( - $immediate === false && ! $definition->immediate - ) { - return false; - } - + if (! empty($conversions)) { + foreach ($conversions as $conversion) { if ( - ! empty($conversions) && - ! in_array($definition->name, $conversions) + $force === false && + $media->hasConversion($conversion) ) { - return false; + continue; } - if ( - ! $force && - $media->hasConversion($definition->name) - ) { - return false; - } - - return true; + $media->dispatchConversion($conversion); } - ); + } else { + $media->dispatchConversions( + queued: true, + filter: function ($definition) use ($media, $force, $immediate) { + + if ( + $immediate === false && + ! $definition->immediate + ) { + return false; + } + + if ( + $force === false && + $media->hasConversion($definition->name) + ) { + return false; + } + + return true; + } + ); + } $progress->advance(); } diff --git a/src/Models/Media.php b/src/Models/Media.php index bf2d09f..2938660 100644 --- a/src/Models/Media.php +++ b/src/Models/Media.php @@ -243,7 +243,11 @@ public function getChildrenConversionsDefinitions(string $name): array public function dispatchConversion(string $conversion): ?PendingDispatch { if ($definition = $this->getConversionDefinition($conversion)) { - return $definition->dispatch($this, $this->getParentConversion($conversion)); + $parent = $this->getParentConversion($conversion); + + if ($definition->shouldExecute($this, $parent)) { + return $definition->dispatch($this, $parent); + } } return null;