okipa / laravel-medialibrary-ext
spatie/laravel-medialibrary 包的额外功能。
Requires
- php: 8.1.*|8.2.*
- illuminate/contracts: ^9.0|^10.0
- spatie/laravel-medialibrary: ^10.0
- symfony/mime: ^6.0
Requires (Dev)
- brianium/paratest: ^6.4
- laravel/pint: ^1.1
- nunomaduro/collision: ^6.0
- nunomaduro/larastan: ^2.0
- orchestra/testbench: ^7.0|^8.0
- phpmd/phpmd: ^2.11
- roave/security-advisories: dev-latest
- dev-master
- 10.2.0
- 10.1.0
- 10.0.2
- 10.0.1
- 10.0.0
- 9.2.0
- 9.1.0
- 9.0.0
- 8.1.0
- 8.0.1
- 8.0.0
- 7.19.3
- 7.19.2
- 7.19.1
- 7.19.0
- 7.18.0
- 7.17.3
- 7.17.2
- 7.17.1
- 7.17.0
- 7.16.0
- 7.15.1
- 7.15.0
- 7.14.5
- 7.14.4
- 7.14.3
- 7.14.2
- 7.14.1
- 7.14.0
- 7.13.4
- 7.13.3
- 7.13.2
- 7.13.1
- 7.13.0
- 7.12.2
- 7.12.0
- 7.11.0
- 7.10.0
- 7.9.0
- 7.8.2
- 7.8.1
- 7.8.0
- 7.7.0
- 7.6.9
- 7.6.8
- 7.6.7
- 7.6.6
- 7.6.5
- 7.6.4
- 7.6.3
- 7.6.2
- 7.6.1
- 7.6.0
- 7.5.6
- 7.5.5
- 7.5.4
- 7.5.3
- 7.5.2
- 7.5.1
- 7.5.0
- 7.4.3
- 7.4.2
- 7.4.1
- 7.4.0
- 7.3.12
- 7.3.11
- 7.3.10
- 7.3.9
- 7.3.8
- 7.3.7
- 7.3.6
- 7.3.5
- 7.3.4
- 7.3.3
- 7.3.2
- 7.3.1
- 7.3.0
- 7.1.8
- 7.1.7
- 7.1.6
- 7.1.5
- 7.1.4
- 7.1.3
- 7.1.2
- 7.1.1
- 7.1.0
- 7.0.6
- 7.0.5
- 7.0.4
- 7.0.3
- 7.0.2
- 7.0.1
- 7.0.0
- 6.9.2
- 6.9.1
- 6.9.0
- 6.8.0
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2.5
- 3.2.4
- 3.2.3
- 3.2.2
- 3.2.1
- 3.2.0
- 3.1.5
- 3.1.4
- 3.1.3
- 3.1.2
- 3.1.1
- 3.1.0
- 3.0.1
- 3.0.0
- 2.3.0
- 2.2.3
- 2.2.2
- 2.2.1
- 2.2.0
- 2.1.5
- 2.1.4
- 2.1.3
- 2.1.2
- 2.1.1
- 2.1.0
- 2.0.1
- 2.0.0
- 1.6.2
- 1.6.1
- 1.6.0
- 1.5.6
- 1.5.5
- 1.5.4
- 1.5.3
- 1.5.2
- 1.5.1
- 1.5.0
- 1.1.4
- 1.1.3
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0.0
- 0.1.0
This package is auto-updated.
Last update: 2024-09-19 23:17:53 UTC
README
本扩展包为 spatie/laravel-medialibrary 包提供额外功能。
觉得这个包有帮助?请考虑支持我的工作!
兼容性
此扩展包将遵循 基本包 的主要版本,但在兼容性约束方面可能更为严格。
升级指南
目录
安装
首先,请务必遵循基本包的安装说明
- https://github.com/spatie/laravel-medialibrary#installation
- https://docs.spatie.be/laravel-medialibrary/v8/installation-setup
然后,通过 composer 安装扩展
composer require okipa/laravel-medialibrary-ext
最后,实现 ExtendsMediaAbilities 特性,以便能够使用扩展功能以及基本包的功能。
use Illuminate\Database\Eloquent\Model; use Okipa\MediaLibraryExt\ExtendsMediaAbilities; use Spatie\MediaLibrary\HasMedia; use Spatie\MediaLibrary\InteractsWithMedia; class Page extends Model implements HasMedia { use InteractsWithMedia; use ExtendsMediaAbilities; // ... }
文档
基本包的完整文档请在此处查看: https://docs.spatie.be/laravel-medialibrary/v8/introduction。
翻译
所有标题都是可翻译的。
请参考 Laravel 官方文档了解如何翻译它们: https://laravel.net.cn/docs/localization#using-translation-strings-as-keys。
以下是可翻译的句子列表
最小宽度::width 像素。最小高度::height 像素。{1}接受类型::types.|[2,*]接受类型::types。最大文件大小::size Mb。
扩展功能
媒体验证规则
按照如下方式声明您的媒体验证规则
// In your user storing form request for example public function rules() { return [ 'avatar' => (new User)->getMediaValidationRules('avatar'), // your other validation rules ]; }
将生成
// Example ['mimetypes:image/jpeg,image/png', 'mimes:jpg,jpeg,jpe,png', 'dimensions:min_width=60,min_height=20', 'max:5000'];
可用的公共方法
->getMediaValidationRules(string $collectionName): array:返回给定集合的所有验证规则。->getMediaMimesValidationRules(string $collectionName): string:返回给定集合的仅 mime 验证规则。->getMediaMimeTypesValidationRules(string $collectionName): string:返回给定集合的仅 mime 类型验证规则。->getMediaDimensionValidationRules(string $collectionName): string:返回给定集合的仅尺寸验证规则。->getMediaSizeValidationRule(): string:返回来自基本包配置值media-library.max_file_size的仅最大文件大小验证规则。
媒体标题
在文件输入下添加约束标题
<!-- In your HTML form --> <label for="avatar">Choose a profile picture:</label> <input type="file" id="avatar" name="avatar" value="{{ $user->getFirstMedia('avatar')->name }}"> <small>{{ $user->getMediaCaption('avatar') }}</small>
将生成
<!-- Example -->
Min. width: 150 px. Min. height: 70 px. Accepted types: jpg, jpeg, jpe, png. Max file size: 5Mb.
可用的公共方法
getMediaCaption(string $collectionName): string:返回给定集合的完整标题。getMediaDimensionsCaption(string $collectionName): string:返回给定集合的仅尺寸标题。getMediaMimeTypesCaption(string $collectionName): string:返回给定集合的仅 mime 类型标题。getMediaSizeCaption(): string:仅返回配置的最大文件大小标题。
异常
为了在使用本扩展提供的需要string $collectionName参数的公共方法时避免粗心错误,当给定的集合名称在目标模型中找不到时,将抛出Okipa\MediaLibraryExt\Exceptions\CollectionNotFound异常。
测试
composer test
变更日志
有关最近更改的详细信息,请参阅更改日志。
贡献
有关详细信息,请参阅贡献指南。
安全性
如果您发现任何安全问题,请通过电子邮件arthur.lorent@gmail.com联系,而不是使用问题跟踪器。
鸣谢
许可证
MIT许可证(MIT)。有关更多信息,请参阅许可证文件。
