arillo / silverstripe-shortpixel
为SilverStripe CMS提供Shortpixel集成。
dev-master
2019-09-26 15:33 UTC
Requires
This package is auto-updated.
Last update: 2024-09-27 02:49:33 UTC
README
注意:正在开发中,请不要在生产环境中使用!
它将通过shortpixel api逐渐优化给定文件夹(例如,资产文件夹)中的所有图像。旨在通过cronjob运行。
添加Shortpixel选项卡到您的SiteConfig,您可以在其中关闭任务执行,并查找api状态信息。
配置
获取shortpixel api密钥并将其设置在您的.env
SP_APIKEY="<YOUR_SHORTPIXEL_API_KEY>"
配置文件(例如,shortpixel.yml)
---
Name: myshortpixelconfig
After:
- '#shortpixelconfig'
---
Arillo\Shortpixel\Shortpixel:
# all option in: ShortPixel\ShortPixel::$options
options:
lossy: 0 # 1 - lossy, 2 - glossy, 0 - lossless
Arillo\Shortpixel\Tasks\FolderTask:
exclude_folders:
- '.protected' # omit .protected, default nothing
# configure ShortPixel
shortpixel_settings:
max_allowed_files_per_call: 5 # default: 10
client_max_body_size: 20 # default: 48
wait: 300 # default: 500
# you can turn off auto file re-hashing, if you want to.
# plays nice with beforeShortPixelCall and afterShortPixelCall hooks, to create your own recovery strategy
use_simple_image_recovering: false # default true
# optionally you can set the root folder
root_folder: <ABSOLUTE_PATH_TO_ROOT_FOLDER> # default ASSETS_PATH
设置cronjob以执行任务
*/1 * * * * php vendor/silverstripe/framework/cli-script.php dev/tasks/ShortpixelFolderTask
您可能需要调整cronjob时间和shortpixel_settings以避免多次重叠执行。
在Arillo\Shortpixel\Tasks\FolderTask中查找有关选项和设置的更多信息。