add image width variable to generation thumbnail queue action

This commit is contained in:
Milos Holba
2021-12-08 18:50:27 +01:00
parent c6b4a767da
commit 5382da0b1f

View File

@@ -20,14 +20,17 @@ class CreateImageThumbnailAcionQueue
{
// Get image from disk
$image = Storage::disk('local')->get("temp/$user_id/{$file_name}");
// Get image width
$image_width = getimagesize(storage_path("app/temp/$user_id/{$file_name}"))[0];
collect($thumnails_sizes)
->each(function ($size) use ($image, $user_id, $file_name) {
// Create intervention image
$intervention = Image::make($image)->orientate();
if ($intervention->getWidth() > $size['size']) {
->each(function ($size) use ($image, $user_id, $file_name, $image_width) {
if ($image_width > $size['size']) {
// Create intervention image
$intervention = Image::make($image)->orientate();
// Generate thumbnail
$intervention->resize($size['size'], null, fn ($constraint) => $constraint->aspectRatio())->stream();