novactive / ezfastlyiobundle
Novactive eZ Fastly Image Optimizer Bundle 是一个用于图像优化和处理的 eZPlatform 插件包。
Requires
- php: ^7.3
This package is auto-updated.
Last update: 2024-09-21 15:33:05 UTC
README
此存储库是一个“子树拆分”:主存储库中的一个目录的只读副本。它由 Composer 使用,允许开发者依赖特定的插件包。
如果您想报告或贡献,您应该在主存储库中打开问题:[https://github.com/Novactive/Nova-eZPlatform-Bundles](https://github.com/Novactive/Nova-eZPlatform-Bundles)
文档可通过此存储库中的 .md 文件获取,也在此打包:[https://novactive.github.io/Nova-eZPlatform-Bundles/master/NovaeZFastlyImageOptimizerBundle/README.md.html](https://novactive.github.io/Nova-eZPlatform-Bundles/master/NovaeZFastlyImageOptimizerBundle/README.md.html)
Novactive eZ Fastly Image Optimizer Bundle 是一个用于图像优化和处理的 eZPlatform 插件包。
此插件包将 Fastly Image Optimization API 的功能引入到您的 eZ Platform 项目中。
插件允许您在 eZ Variations 之上定义 Fastly Image Optimization 变体。根据您的配置,图像源将适配以注入 Fastly Image Optimization 参数。
所有配置都是 SiteAccessAware 的,因此您可以根据 SiteAccess 有不同的配置。
安装
使用 Composer
将库添加到您的 composer.json 中,运行 composer require novactive/ezfastlyiobundle
以刷新依赖项。
然后,将插件注入到您应用程序的 bundles.php
中。
Novactive\Bundle\eZFastlyImageOptimizerBundle\NovaeZFastlyImageOptimizerBundle::class => [ 'all'=> true ],
使用方法
此插件包模仿了原生图像变体系统。
nova_ezfastlyio: system: default: fastlyio_variations: bright: filters: width: 200 brightness: -50 blur: 50
您还可以提供参考变体。不建议这样做,使用原始变体在 Fastly 上提供更好的结果,并避免在 eZ 端生成变体。
nova_ezfastlyio: system: default: fastlyio_variations: ezreference_variation: medium bright: filters: width: 200 brightness: -50 blur: 50
在此配置中,Fastly Image Optimizer 将处理中等变体。
在您的模板中
{{ ez_render_field( content, "image",{ "parameters": {"alias": 'simpletest2'}, "attr" : { "class" : "img-responsive" } } ) }}
自动地,将使用 nova_ezfastlyio_alias
而不是 ez_image_alias
。如果别名名称不在 fastlyio_variations
中,插件将回退到原生变体系统。
然后,基本上您的代码不会有任何变化,只需为您的变体提供 yaml 配置即可。
如果您已覆盖了内容字段,请确保更新对
nova_ezfastlyio_alias
的调用。
如何管理本地开发
在本地,您将没有 Fastly Image Optimizer,系统将仅将参数添加到您图像的 URI 中。
根据您的需求,您可能希望禁用 FastlyIO 变体。
# config/packages/dev/variations.yaml nova_ezfastlyio: system: site: fastlyio_disabled: true
这不是必需的,=