mezcalito / imgproxy-bundle
0.2.0
2024-01-08 07:31 UTC
Requires
- php: ^8.1
- symfony/framework-bundle: ^5.4 || ^6.0 || ^7.0
- symfony/http-foundation: ^5.4 || ^6.0 || ^7.0
- symfony/string: ^5.4 || ^6.0 || ^7.0
- twig/twig: ^2.7 || ^3.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.16
- phpstan/phpstan: ^1.10
- phpunit/phpunit: ^10.1
README
安装
在终端运行此命令
composer require mezcalito/imgproxy-bundle
如果您不使用Symfony Flex,您必须手动在应用程序中启用此包
<?php return [ // ... Mezcalito\ImgproxyBundle\ImgproxyBundle::class => ['all' => true] ];
基本用法
此包通过在模板或代码中对图片应用预设来工作。您的预设定义在应用程序的配置文件中(/config/packages/imgproxy.yaml
)。
目前,此包只提供了一个预设:resize
预设。以后将添加更多功能。
要使用此包,创建以下文件
# config/packages/imgproxy.yaml imgproxy: host: localhost media_url: https://media.localhost # set the same key and salt in imgproxy environment (https://docs.imgproxy.net/signing_the_url) signature: key: c27f2c1d salt: fa242e79 # default settings applied for all presets default_preset_settings: format: webp encode: true presets: # this is a preset example with all the configuration available png_thumbnail: format: png resize: resizing_type: fit width: 150 height: 75 enlarge: true extend: extend: true gravity: type: no x_offset: 10 y_offset: 10
然后,您可以在模板中使用您的预设
<img src="{{ asset('/relative/path/to/image.jpg') | imgproxy_preset('png_thumbnail') }}" />
问题和功能请求
请在https://github.com/mezcalito/imgproxy-bundle/issues处报告问题和请求功能。
许可证
此包遵循MIT许可证。有关完整版权信息,请参阅与此源代码一起分发的LICENSE文件。