diff --git a/src/Commands/RegenerateThumbnails.php b/src/Commands/RegenerateThumbnails.php index 4694131..bc97e47 100644 --- a/src/Commands/RegenerateThumbnails.php +++ b/src/Commands/RegenerateThumbnails.php @@ -48,12 +48,14 @@ public function handle() $updateCount = 0; $totalCount = $medias->count(); - $rootPath = storage_path('app/'); $this->output->write("\n"); + foreach ($medias as $media) { - if ($handler->isReadableImage($rootPath . $media->path . $media->file_name)) { + $mediaPath = $media->getDisk()->path($media->file_path); + + if ($handler->isReadableImage($mediaPath)) { try { - $generatedImages = $handler->generateImageSizes(file_get_contents($rootPath . $media->path . $media->file_name), $media->path . $media->file_name, Storage::disk('local')); + $generatedImages = $handler->generateImageSizes(file_get_contents($mediaPath), $media->file_path, $media->mime_type, $media->getDisk()); $media->image_sizes = json_encode($generatedImages); $media->save(); } catch (\Exception $e) {