Package Data | |
---|---|
Maintainer Username: | kujjs |
Maintainer Contact: | contacto@kujjs.com (Nelson Jara) |
Package Create Date: | 2016-08-08 |
Package Last Update: | 2024-05-31 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-19 03:15:02 |
Package Statistics | |
---|---|
Total Downloads: | 1,393 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 1 |
Total Watchers: | 1 |
Total Forks: | 1 |
Total Open Issues: | 4 |
Based on anakadote/laravel-5-image-manager.
Resize images with predefined sizes in config / imageManager.php
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
Set sizes in config/imageManager.php
'sizes' => [
'thumbnail' => [
'width' => 120,
'height' => 120,
'mode' => 'crop', || fit || fit-x || fit-y
'quality' => 90
]
];
| Property || Description |
|--------|----|-------------|
|width
|required|The width of the generated image in pixels.|
|height
|required|The height of the generated image in pixels.|
|mode
|required|Defines the way the image will be transformed. See the table below for accepted modes|
|quality
|required|The quality that will have the final image. range 0-100|
|Mode|Description|
|------|-----------|
|crop
|Will smart crop an image to make it fit the desired dimensions. It will cut content of the image off the top/bottom and sides if required to preserve the aspect ratio.|
|fit
| Fit while maintaining aspect ratio|
|fit-x
| Fit to the given width while maintaining aspect ratio|
|fit-y
| Fit to the given height while maintaining aspect ratio|
{{ Image::make(public_path('img/image.jpg'),'thumbnail') }}
OR
{{ Image::make(public_path('img/image.jpg')) }}
Return
img/120-120/crop/image.jpg
| Property || Description |
|--------|----|-------------|
|File
|required (string)| The fully qualified name of image file. The file must reside in your app's public directory. You'll need to grant write access by the web server to the public directory and its children|
|Size Name
|(optional) (string)|The name of the size that is defined in config/imageManager.php.|
{{ Image::make(public_path('img/image.jpg'),'thumbnail')->toUrl() }}
return
http://mysite.dev/img/120-120/crop/image.jpg
{!! 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">
| Property || Description |
|--------|----|-------------|
|attributes
|optional (array)| Attributes html you can inset in the tag img|
remove image with all size declarade in config/imageManager.php
Image::delete(public_path('img/image.jpg'))
The MIT License (MIT). Please see License File for more information.