inweb / media
Media components for InWeb framework
Installs: 230
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/inweb/media
Requires
- php: ^7.1|^8.0
- intervention/image: ^2.7
- laravel/legacy-factories: ^1.1
- php-ffmpeg/php-ffmpeg: dev-master
Requires (Dev)
- facade/ignition: ^2.17.6
- fakerphp/faker: ^v1.20.0
- laravel/sail: ^v1.15.1
- mockery/mockery: ^1.5.0
- nunomaduro/collision: ^v6.2.1
- phpunit/phpunit: ^9.5.21
README
Media files manipulation
Requirements
- Laravel >=5.7
Installation
- Install package via composer require
or add to your composer.json to require section and update your dependenciescomposer require inweb/media"inweb/media": "*" - Run migrations
php artisan migrate
You are ready to go!
Usage
Add trait to your model (InWeb\Base\Entity)
use InWeb\Media\WithImages;
For thimbnails implement method:
use InWeb\Media\Thumbnail;
...
public function getImageThumbnails()
{
return [
'catalog' => new Thumbnail(function (\Intervention\Image\Image $image) {
return $image->resize(100, 100, function (Constraint $c) {
$c->aspectRatio();
$c->upsize();
})->resizeCanvas(100, 100);
}, true),
];
}
Thumbnail class receives 2 parameters:
- Closure with \Intervention\Image\Image object
- Boolean - Only for main image (default - false)
You can specify original thumbnail name to manipulate with original image.
public function getImageThumbnails()
{
return [
'original' => new Thumbnail(...),
];
}