0

I am new to Laravel and coming from Rails. Was looking for a recommendation for a package for Image handling in Laravel which can do the following?

  • Uploading Images
  • Validation of Images
  • Resizing versioning support
  • Amazon S3 support
Harsha M V
  • 54,075
  • 125
  • 354
  • 529

1 Answers1

1

What I use for these scenarios:

For Image uploads

In general, you do not need any package, Laravel support this pretty well out of the box, including out of the box Amazon S3 support, validation, limiting to a specific file types and/or sizes, etc. (See: Laravel - File Storage)

If you need special validations and/or a drag zone, I would use Laravel file storage together with Dropzone.js on the front-end.

* For Image manipulations

For example, for creating thumbnails, resizing images, etc.) I would use the Intervention Image package, it is very useful and well known in the php community.

Jhonny
  • 457
  • 3
  • 7
  • Thank you. What's the best place to place the resize code for the images? I am not sure if Controller would be the right place. – Harsha M V Sep 20 '19 at 10:39
  • Highly dependent on what you are working on. If it's only an image upload in one place, you should be good with writing the code in the controller, or in a separate ImageController. if it is used in a couple of places and maybe you even keep track of the images in the DB, I would create a Media Modal, that stores the image id/name/dir/path And maybe add the creation of a thumbnail there in a method generateThumbnail that will be used in the controller. – Jhonny Sep 20 '19 at 10:41
  • When someone uploads an image I want to create 2-3 different sizes which we will use around the App. So it should store in S3 and then also resize and store these versions in the same folder. – Harsha M V Sep 20 '19 at 10:45
  • Just remembered there is a good package to do image uploads & create thumbnails and stuff easily, I have used it in the past, It also creates a Media modal and records on media items. You should check it out as well: https://laravel-mediable.readthedocs.io/en/latest/mediable.html – Jhonny Sep 20 '19 at 10:53