kujjs / resize-image
Resize images with predefined sizes
Installs: 1 393
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 1
Open Issues: 4
Requires
- php: ^7.1.3
- anakadote/laravel-5-image-manager: dev-master
- illuminate/support: >=5.8
README
Based on anakadote/laravel-5-image-manager.
Resize images with predefined sizes in config / imageManager.php
Attention!!!!!!!!!!!!
important changes were made in how to obtain the cropped images, please read the new documentation.
If you don't want to replace the changes but want to use Auto-Discovery you can use version 5.5.0
Install
Edit your project's composer.json
"require": { "anakadote/laravel-5-image-manager": "dev-master", "kujjs/resize-image": "^0.5.5.1" }
Add the service provider. config/app.php
'providers' => [ kujjs\imageManager\imageManagerServiceProvider::class, // optional, you can use Auto-Discovery Anakadote\ImageManager\ImageManagerServiceProvider::class, ];
If not use Auto-Discovery your add next alias in config/app.php
'aliases' => [ ... 'Image' => 'kujjs\imageManager\Facades\ImageManager', ];
And run the following command
$ php artisan vendor:publish
Usage
Set sizes in config/imageManager.php
'sizes' => [ 'thumbnail' => [ 'width' => 120, 'height' => 120, 'mode' => 'crop', || fit || fit-x || fit-y 'quality' => 90 ] ];
Image::make($file , $size='thumbnail'))
{{ Image::make(public_path('img/image.jpg'),'thumbnail') }} OR {{ Image::make(public_path('img/image.jpg')) }}
Return
img/120-120/crop/image.jpg
get full url
toUrl()
{{ Image::make(public_path('img/image.jpg'),'thumbnail')->toUrl() }}
return
http://mysite.dev/img/120-120/crop/image.jpg
Get tag img
toHtml( $attributes = [] )
{!! Image::make(public_path('img/image.jpg'),'thumbnail')->toHtml() !!}
Return
<img src="http://mysite.dev/img/120-120/crop/image.jpg">
Or
{!! Image::make(public_path('img/image.jpg'),'thumbnail')->toHtml(['class'=>'my-class','alt'=>'my alt','title'=>'my title', 'attributes'=>'values']) !!}
Return
<img src="http://mysite.dev/img/120-120/crop/image.jpg" "alt"="my alt" "title"="my title" "class"="my-class" "attributes"="values">
Remove
Image::delete($file)
remove image with all size declarade in config/imageManager.php
Image::delete(public_path('img/image.jpg'))
License
The MIT License (MIT). Please see License File for more information.