gromovfjodor / yii2-image-resize
一个用于动态调整图片尺寸的Yii2组件
1.0.1
2019-03-05 10:51 UTC
Requires
README
一个用于调整图片尺寸并将其存储在缓存文件夹中的Yii2组件
安装
安装此扩展的首选方式是通过 Composer。
- 运行以下命令:
php composer.phar require "gromovofjodor/yii2-image-resize" "*"
或者在您的应用程序的 composer.json
文件的 require 部分添加以下内容:
"noam148/yii2-image-resize" : "*"
- 在您的应用程序配置文件的
components
部分添加一个新的组件,例如:
'components' => [ 'imageresize' => [ 'class' => 'noam148\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);
如果您有任何问题、建议或反馈,请告诉我!