mrumengan / yii2-image-resize
一个用于动态调整图像大小的Yii2组件
1.0.2
2024-09-10 06:26 UTC
Requires
This package is not auto-updated.
Last update: 2024-09-24 06:43:57 UTC
README
一个用于调整图像大小并将其存储在缓存文件夹中的Yii2组件
安装
安装此扩展的首选方法是通过 composer。
- 你可以运行以下命令之一:
php composer.phar require "mrumengan/yii2-image-resize" "*"
或者添加以下内容到你的应用程序的 composer.json
文件中的 require 部分:
"mrumengan/yii2-image-resize" : "*"
- 在你的应用程序配置文件的
components
部分添加一个新的组件,例如:
'components' => [ 'imageresize' => [ 'class' => 'mrumengan\imageresize\ImageResize', //path relative web folder. In case of multiple environments (frontend, backend) add more paths 'cachePath' => ['assets/images', '../../frontend/web/assets/images'], //use filename (seo friendly) for resized images else use a hash 'useFilename' => true, //show full url (for example in case of a API) 'absoluteUrl' => false, ], ],
使用方法
如果你想要获取一个图像的URL
/* * $sImageFilePath_id: (required) path to file * $width/$height: (required) width height of the image * $mode: "outbound", "inset" or "{horz}:{vert}" where {horz} is one from "left", "cetrer", "right" and {vert} is one from "top", "center", "bottom" * $$quality: (1 - 100) * $chosenFileName: if config -> components -> imageresize -> useFilename is true? its an option to give a custom name else use original file name */ \Yii::$app->imageresize->getUrl($sImageFilePath, $width, $height, $mode, $quality, $chosenFileName);
如果你有任何问题、建议或反馈,请告诉我!