Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

newsshare24h's avatar

How to determine image uploaded route laravel-filemanager

I'm using "standalone button" for many pages on website (product/create.blade.php, banner/create.blade.php, ...)

$('#lfm').filemanager('image');

And i also call an image handler event after the image is uploaded, based on the answer of Sti3bas:

EventServiceProvider:

protected $listen = [
   //...
   \UniSharp\LaravelFilemanager\Events\ImageWasUploaded::class => [
       \App\Listeners\ResizeUploadedImage::class,
   ],
];

ResizeUploadedImage listener:

use Intervention\Image\Facades\Image;
public function handle($event)
{
    $image = Image::make($event->path());

    if($image->width() <= 1000) {
        return;
    }

    $image->fit(500, 500)->save();
}

But all uploaded images are resized, i just want the images of the product to change, so is there any way to determine the image uploaded from the product/create.blade.php page in the "ResizeUploadedImage" event.

0 likes
0 replies

Please or to participate in this conversation.