Rafaël De Jongh
Rafaël De Jongh

Reputation: 908

Dropzone.JS CreateImage Thumbnails

So I noticed that DropzoneJS has the following Configuration Option being: createImageThumbnails (http://www.dropzonejs.com/#config-createImageThumbnails).

But I didn't find any proper information to how this configuration option can be used, and how I can save thumbnails on my server by using this option.

I'm currently using Laravel 5.3 to do the whole uploading via DropzoneJS so I would like to have some thumbnail control, so my question here is. Would it be a good way to do it via DropzoneJS and if so how? OR do it php wise?

Thanks for further information in advance.

Upvotes: 0

Views: 1126

Answers (1)

Ohgodwhy
Ohgodwhy

Reputation: 50798

I would not recommend using the createThumbnailFromUrl() method which implements createImageThumbnails().

The reason being is that - each time you do this, you'll force the user to create the thumbnail on the client side (CPU/Mem resource intensive). Then, they'll have to send the image to the server (Network/Bandwidth intensive).

Instead, I would recommend just creating the thumbnails on the server. You can scale down the images on the client side (the original) for viewing with minimal resource cost (zero network/bandwidth cost).

The server can then handle the thumbnail creation. You can use something such as the Intervention library's fit() command for this. Here's an example using a callback to ensure that the image does not get made any larger than the original in either dimension calling ->upsize().

$img = Image::make('/path/to/my/img.ext');
$img->fit(120, 72, function ($constraint) {
    $constraint->upsize();
});

Hope this was informative and helpful.

Upvotes: 2

Related Questions