Downloads
Stars
Version
Laravel package gives you full control of uploading, managing and manipulating app images.
In laravel public folder create uploads folder and then create a folder for whatever type of image you will upload, let's named for example users, and add to it .gitignore file with
*
!.gitignore
to prevent images to upload to git.
composer require hesham14yahia/image-full-control
Just add
use Hesham14Yahia\ImageFullControl\ImageFullControl;
in your controller, then call static method uploadImage()
ImageFullControl::uploadImage($image, $folder_name)
just only two required parameters, first one the submitted image from the form, and the second one is the folder name, if you used in your method Independy Injection "Request" with the input file name "image" and folder name "users", it will be like that.
ImageFullControl::uploadImage($request->image, "users");
the method returns the uploaded image name.
You can update image field with it, by adding the third parameter, which is an old image name, if we stick with the user example, and you created an instance of the user model, it will be like that.
ImageFullControl::uploadImage($request->image, "users", $user->image);
the method returns the new uploaded image name and deletes the old one, if you don't want to delete the old image, just don't pass it.
Determine image width or height or even quality, all this is optional, but they have an order you should stick with it, so if you will use all, it will be like that.
ImageFullControl::uploadImage($request->image, "users", $user->image, 50, 100, 75);
it will make the image with width 50px and height 100px and quality 75%, if you want to use only quality for example, it will be like that.
ImageFullControl::uploadImage($request->image, "users", $user->image, null, null, 11);
Note: default quilty is 100%.
To make handling images easier, start from version 1.3.0
we add method returns image full path accepts folder name and image name, it will be like that.
ImageFullControl::imageFullPath("users", $image_name);