Awar Pulldozer
Awar Pulldozer

Reputation: 1101

Load big size images as thumb

Hi I'm working with project that upload images as attachment everything working cool except that when I upload image from mobile its like 3 or 4 MB size, so when I view the images page took lots of time to load.

this is my example :
enter image description here
Now when someone click on theses images it will redirect to full image size in blank page, now is there anyway to load images as thumb 50*50 from the original size thanks

Upvotes: 0

Views: 163

Answers (1)

Mihir Bhende
Mihir Bhende

Reputation: 9055

When you are saving these images in the storage, you need to also on the fly create thumbnails for the same. And then use those when you need.

There are awesome packages available for the same of which intervention is the best one as per my opinion.

When you use this package, you can simply do :

// Make thumbnail of existing image : 

$img = Image::make('public/foo.jpg')->resize(50, 50)->insert('public/foo50x50.png');

// Create thumbnail on the fly for uploaded images from fomr request

$image = $request->file('image');

$thumbnail = Image::make($image->getRealPath())->resize(50, 50)->save($destinationPath.'/'.$fileThumbnailName);

$image->move($destinationPath, $filaName);

Upvotes: 1

Related Questions