This commit is contained in:
2024-06-05 14:12:54 +02:00
parent dd341ed642
commit d01c7d3868
2 changed files with 8 additions and 39 deletions

View File

@@ -10,6 +10,7 @@ use Illuminate\Support\Facades\Storage;
use Intervention\Image\Laravel\Facades\Image as InterventionImage;
use \App\Importers\Image\Jobs\GenerateThumbnail;
use \App\Importers\Image\Jobs\GenerateFullscreen;
use Illuminate\Support\Facades\Bus;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Image>
@@ -31,10 +32,13 @@ class ImageFactory extends Factory
$width = rand(2000, 4000);
$image_content = Http::get("https://picsum.photos/{$width}/{$height}")->body();
$encoded = InterventionImage::read($image_content)->toAvif(config('gallery.image.quality'));
Storage::disk('images')->put($image->album->id . '/original/' . $image->id . '.avif', $encoded);
$image_path = $image->album_id . '/original/' . $image->id . '.avif';
Storage::disk('images')->put($image_path, $encoded);
GenerateThumbnail::dispatch($image);
GenerateFullscreen::dispatch($image);
Bus::batch([
new GenerateThumbnail($image),
new GenerateFullscreen($image),
])->name('seeder_import_batch_' . $image->id)->dispatch();
});
}