whitepottery / up-file
Expa
dev-master
2023-10-05 08:03 UTC
Requires
- php: ^7.3|^8.0
This package is not auto-updated.
Last update: 2024-10-03 12:42:59 UTC
README
使用 composer 安装
composer require whitePottery/up-file
发布 js 文件、视图和迁移文件以使包工作。调用命令
php artisan vendor:publish --tag=upfile
执行迁移
php artisan migrate
在 Html.blade 文件中,在底部添加样式 @stack('styles') 和底部脚本 @stack('scripts')
在将用于处理带图像帖子模型中创建 ImageModel 的扩展
示例
use UpFile\Models\ImageModel;
class Blog extends ImageModel
{
}
在将上传图像的表单文件中插入组件。例如:博客管理员的创建页面
<x-upfile-cut-img class="" name="mini-blog" width="500" height="300" max-height="700"/>
博客管理员的编辑页面
<x-upfile-cut-img class="" :post-id="$blog->id" name="mini-blog" width="500" height="300"/>
在将显示图像的 blade.php 文件中插入组件,例如:主页博客
<x-upfile-print-img name="image-blog" :post-id="$blog->id" class="slider"/>
编辑图像输出的文件位于文件夹:resources/views/vendor/print-img/print-img.blade.php
属性
组件 <x-upfile-cut-img/> 的属性
- name - 标签名称+模型名称通过破折号连接(name-model)。
- :post-id - 在编辑表单中用于获取数据。
- class - 可以添加 CSS 类到图像上。
- width(height) - 剪切后缩略图的宽度和高度(像素)。
- max-width(max-height) - 上传后主图像的宽度和高度。如果同时存在两个参数,则压缩将根据高度进行。如果 max-width 或 max-height 等于 "100%",则不会进行压缩,图片将保持原始大小。如果没有 max-width 和 max-height,则将输出手动剪切后的图片。
组件 <x-upfile-print-img/> 的属性
- name - 标签名称+模型名称通过破折号连接(name-model)。
- :post-id - 在编辑表单中用于获取数据。
- class - 可以添加 CSS 类到图像上。
如果没有创建 storage 文件夹的链接,请输入命令
php artisan storage:link
删除包
composer remove whitePottery/up-file