aquinoaldair / storage-image
Easy images storage for Laravel
Installs: 153
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 1
Open Issues: 0
Language:HTML
Requires
- intervention/image: ^2.5
Requires (Dev)
- orchestra/testbench: ^3.8
README
Store Image for Laravel
Laravel library for easy store images in public storage.
Installation
You can install the package via composer:
composer require aquinoaldair/storage-image
Usage
use AquinoAldair\StorageImage\StorageImage;
Store from Base64
$image = "data:image/png;base64....."; //store image with random 20 character name in Storage disk public (storage/app/public/customFolder) $file_name = StorageImage::FromBase64($image)->store("custom_folder"); echo $file_name; // "custom_folder/jqmix7a1l6masdGasd7S.jpg"
Store from FormData
$image = request()->image; $file_name = StorageImage::FromFormData($image)->store("custom_folder");
Store from URL
$url = "https://homepages.cae.wisc.edu/~ece533/images/airplane.png"; $file_name = StorageImage::FromURL($url)->store("custom_folder");
Return only string
$url = "https://homepages.cae.wisc.edu/~ece533/images/airplane.png"; $file_name = StorageImage::FromString($url)->store("custom_folder"); echo $file_name; // "https://homepages.cae.wisc.edu/~ece533/images/airplane.png"
Implement your own storage method
<?php namespace AquinoAldair\StorageImage\Strategies; use AquinoAldair\StorageImage\Contract\Image; class MyCustomClass implements Image { protected $file; public function __construct($file) { $this->file = $file; } public function store($folder = null) { // do something } } $image = "something"; StorageImage::make(new MyCustomClass($image))->store("custom_folder");
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.