imponeer / smarty-image
Smarty 插件,增加了某些与图像相关的模板语法增强
v2.0.2
2023-07-01 17:40 UTC
Requires
- php: ^7.3|^8.0
- ext-json: *
- imponeer/smarty-extensions-contracts: ^3.0
- intervention/image: ^2.5
- psr/cache: ^1.0|^2.0|^3.0
Requires (Dev)
- bentools/cartesian-product: ^1.3
- phpunit/phpunit: ^8.0 || ^9.0
- symfony/cache: ^5.0|^6.0
- symfony/dom-crawler: ^5.0|^6.0
- symfony/polyfill-php80: ^1.27
README
Smarty Image
一些用于图像操作的 Smarty 语法插件。
安装
要安装和使用此包,我们建议使用 Composer
composer require imponeer/smarty-image
否则,您需要手动包含来自 src/
目录的文件。
在 Smarty 中注册
如果您想使用此包中的这些扩展功能,您需要使用 registerPlugin
函数 从 Smarty 注册它们。例如
$smarty = new \Smarty(); $resizeImagePlugin = new \Imponeer\Smarty\Extensions\Image\ResizeImageFunction($psrCacheAdapter); $smarty->registerPlugin('function', $resizeImagePlugin->getName(), [$resizeImagePlugin, 'execute']);
从模板中使用
要使用 smarty 调整图像大小,您可以使用 resized_image 函数
{resized_image file="/images/image.jpg" height=70}
此函数支持以下参数
所有额外参数将在返回模式为 image
时渲染到图像标签中。
如何贡献?
如果您想添加一些功能或修复错误,您可以 fork、更改并创建 pull request。如果您不确定如何操作,请尝试 交互式 GitHub 教程。
如果您发现任何错误或有任何问题,请使用 问题标签 并在那里写下您的问题。