beestreams / laravelimageable
Add images to your models. Resizes images
Requires
- intervention/image: ^2.4
This package is not auto-updated.
Last update: 2025-03-16 04:16:09 UTC
README
Usage
- Install via composer
- If Laravel 5.4 or lower, add service provider
Beestreams\LaravelImageable\ImageableProvider::class
- run
php artisan vendor:publish --tag=config
- Migrate database
- Include Imageable trait on models
- Set upload path on model
protected $imagePath = 'example/'
- When file is available, add it to model
$model->attachImage($file);
When file is added to model, it first persists an Image model to DB it then saves the file to specified path. You can set sizes in config to make several images. These are jobs dispatched to queue. For each image size it makes an additional model. When model is deleted, it also deletes the file. When original model is deleted all related models and files are deleted
For method list see Imageable
trait or IntegrationTest
If you want alt_text and description for your files … support for that is coming
TODO:
- Get file from url (route and response)
- Multiple file types support
- SVG support
- create failsafe in ResizeImage job. If size does not exist, fail gracefully
- Integrationtest is a test-dump. Clean up and refactor
- Fix hacky Job handle method
- Whats up with all the save methods?
- External storage services
- Delete all sizes on delete
- Create controller for image and refactor routes file
- If file directory is empty remove directory on delete
Important
There is no validation in this package, please validate your requests before using.
Vendor publish
If you need to modify migrations, models or traits you can ´vendor:publish´ this package. (not tested)