Download the PHP package ankitpokhrel/laravel-image without Composer
On this page you can find all versions of the php package ankitpokhrel/laravel-image. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ankitpokhrel/laravel-image
More information about ankitpokhrel/laravel-image
Files in ankitpokhrel/laravel-image
Package laravel-image
Short Description Easy image upload and thumbnail management
License MIT
Informations about the package laravel-image
Laravel Image
Image Upload Package for Laravel 5+
Overview
Laravel Image is a image upload and thumbnail management package for laravel 5+. This package uses Glide library from the php league for on-demand image manipulation.
Installation
For 5.1 use 5.1 branch.
For 5.2 use 5.2 branch.
For 5.3 use master branch.
Pull the package via composer
Include the service provider within config/app.php
.
Finally publish the configuration
Configuration
You can add default configurations to config/laravelimage.php
.
Usage
Uploading Image
Within your controllers, get access to image upload service via dependency injection
And then, in your store or update method you can perform image upload
Uploaded file info
You can get uploaded file info using $this->image->getUploadedFileInfo()
. It will return array as follow:
To change image
field you can use setUploadField()
method. If you wish to change upload_dir
field you can use setUploadDir
method. Usually you will save image
, upload_dir
and original_image_name
to the database.
To get validation errors, you can use getValidationErrors()
method.
Customizing upload path
Sometime you may want to group uploaded image or even store image somewhere else other than the public folder.
You can do it by setting base path. For example, this settings below will store images inside
public/uploads/user-images/users/
directory.
If you want to upload image in other places other than public
folder, you can provide second parameter as false
to the base path method.
This will upload image to /absolute/path/to/your/folder/uploads/users
folder. Make sure that the folder has proper
permission to store the images.
Using blade directive to display images
Display full image
Create image of custom size at runtime
Options & attributes
Options can be any glide options. See thephpleague/glide for more info on options.
Displaying image without blade
Image source should be in the format laravelimage.routePath/uploadDir/image?options
, where laravelimage.routePath
is from configuration file.
So if you set your routePath
to cache
, the image url will be something like this.
Generated images are cached inside storage/laravel-image-cache
.
All versions of laravel-image with dependencies
laravel/framework Version 5.3.*
league/glide-laravel Version ^1.0
phpunit/phpunit Version 5.5.*