pyaehein / laravellqip
Laravel 的 LQIP 图像处理。
v0.1.1
2017-06-08 15:34 UTC
Requires
- intervention/image: ^2.3
This package is not auto-updated.
Last update: 2024-09-29 01:39:19 UTC
README
Laravel LQIP 包,包括
- 低质量图像自动创建;
- 使用 lazysize 替换 src
在 Laravel 5.4 上安装
- 在终端运行
$ composer require pyaehein/laravellqip
- 在 config/app.php 中添加服务提供者
PyaeHein\LQIP\LQIPServiceProvider::class,
- 然后在终端运行几个命令
$ php artisan vendor:publish
- 在 blade 的头部添加脚本
<script src="{{ asset('vendor/lqip/lazysizes/lazysizes.min.js')}}" async=""></script>
<style> .blur-up { -webkit-filter: blur(25px); filter: blur(25px); transition: filter 400ms, -webkit-filter 400ms; } .blur-up.lazyloaded { -webkit-filter: blur(0); filter: blur(0); } </style>
- 像这样应用你的图像
<img {!! lqip('helloworld.jpg') !!} class="lazyload blur-up" >
- 在 filesystems.php 中添加存储磁盘
'lqip' => [ 'driver' => 'local', 'root' => public_path('uploads/images') ],
- 更改 config/lqip.php 中的 lqip 配置
return [ 'path' => 'uploads/images', 'disk' => 'lqip', 'prefix' => '_lqip', 'format' => 'jpg', 'blur' => '99', // 0 to 100 'quality' => '1' // 0 to 100 ];
记住
配置文件中的 'path' 用于图像库干预自动创建 lqip 图像。因为,它不支持 Laravel 的文件系统。所以,你的 lqip 图像只能创建在你的公共文件夹中 :(
注意
我只是为了我的项目需求而创建它。所以,它可能无法满足你的需求。
致谢
许可证
Laravel LQIP 对非商业用途免费。