w360 / image-storage
多尺寸图片上传库
2.0.5
2023-05-11 22:36 UTC
Requires
- intervention/image: ^2.7.2
Requires (Dev)
- laravel/legacy-factories: ^v1.3.2
- orchestra/testbench: ^7.24
README
用于w360项目的react基础模块
目录
安装
> composer require w360/image-storage
示例
- 用户上传个人照片的示例
<?php namespace App\Http\Controllers; use App\Models\User; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; use W360\ImageStorage\Facades\ImageST; class TestController extends Controller { private function saveProfile(Request $request){ if($request->hasFile('photo') and Auth::check()){ $storage = 'photos'; $photo = $request->photo; $user = User::findOrFail(Auth::user()->id); ImageST::updateOrCreate($photo, $storage, $user); } } }
<?php namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Notifications\Notifiable; use Laravel\Sanctum\HasApiTokens; use W360\ImageStorage\Models\ImageStorage; class User extends Authenticatable { use HasApiTokens, HasFactory, Notifiable, HasImages; public function getPhotoAttribute(){ return $this->images()->first(); } }
show uploaded image @php($photo = Auth::user()->photo) @if($photo) <img src="{{ image($photo->name, $photo->storage) }}" alt="image uploaded with w360/image-storage" /> get xs image <img src="{{ image($photo->name, $photo->storage, 'xs') }}" alt="image uploaded with w360/image-storage xs size" /> ... get xxl image <img src="{{ image($photo->name, $photo->storage, 'xxl') }}" alt="image uploaded with w360/image-storage xxl size" /> @endif
特性
- 允许轻松上传图片到存储
- 允许您根据相应的质量设置生成图片的多个尺寸
库
- Image Intervention https://image.intervention.io/v2/introduction/installation
许可证
MIT许可证 (MIT)
版权所有 (c) 2023 W360 S.A.S
在此特此授予任何获得此软件及其相关文档文件(以下简称“软件”)副本的任何人,免费使用该软件的权利,不受限制,包括但不限于使用、复制、修改、合并、发布、分发、再许可和/或销售软件副本的权利,以及允许向软件提供的人这样做,但受以下条件约束:
上述版权声明和本许可声明应包含在软件的所有副本或主要部分中。
软件按“原样”提供,不提供任何明示或暗示的保证,包括但不限于适销性、特定用途的适用性和非侵权性。在任何情况下,作者或版权所有者不应对任何索赔、损害或其他责任负责,无论是基于合同、侵权或其他方式,无论是由于软件本身、使用或以其他方式与之相关而产生的。