e200 / mediavel
Laravel media library package
dev-master
2019-12-04 08:30 UTC
Requires
- illuminate/support: ~5
- intervention/image: ^2.4
Requires (Dev)
- mockery/mockery: ^1.1
- orchestra/testbench: ~3.0
- phpunit/phpunit: ~7.0
- sempro/phpunit-pretty-print: ^1.0
This package is auto-updated.
Last update: 2025-03-29 01:09:50 UTC
README
A media library handler for Laravel.
Right now, it only supports upload images and generate thumbnails from them.
Installation
Via Composer
$ composer require e200/mediavel
Usage
namespace App\Http\Controllers; use Illuminate\Routing\Controller; use e200\Mediavel\Facades\MediaLibrary; class ImageController extends Controller { public function upload(Request $request) { $uploadedImage = $request->image; $media = $mediaLibrary ->add($uploadedImage) // Store the image ->preserveOriginal() // Do not touch the original file ->resize('small', [75, 75]) // Creates a thumbnail (75x75) derived from the original image ->resize('medium', [150, 150]) // Creates a thumbnail (150x150) ->resize('large', [1024, 300]); // Creates a thumbnail (1024x300); $media->id; // 1 $media->relative_path; // /images/2018/12/sl290s8xq0is9wqjk.jpg $media->url; // http://localhost:8000/images/2019/06/5cf6976f20dfb.jpg $thumbs = $media->thumbs(); $thumbs['small']->path; // /images/2018/12/5cf6976f20dfb-75x75.jpg $thumbs['medium']->path; // /images/2018/12/5cf6976f20dfb-150x150.jpg $thumbs['large']->path; // /images/2018/12/5cf6976f20dfb-1024x300.jpg } }
Change log
Please see the changelog for more information on what has changed recently.
Testing
$ composer test
Contributing
Please see contributing.md for details and a todolist.
Security
If you discover any security related issues, please email eleandro@inbox.ru instead of using the issue tracker.
Credits
License
MIT. Please see the license file for more information.