artkost/yii2-image-style-behavior
最新稳定版本:0.1
Composer 安装命令:
composer require artkost/yii2-image-style-behavior
包简介
Yii 2 image styles generation behavior
关键字:
README 文档
README
Create sets of styles for your images
Installation
The preferred way to install this extension is through composer.
Either run
$ composer require artkost/yii2-image-style-behavior
or add
"artkost/yii2-image-style-behavior": "*"
to the require section of your composer.json file.
Configuring
Configure model as follows
use artkost\imagestyle\ImageStyleBehavior; class ImageFile extends \yii\db\ActiveRecord { public function behaviors() { return [ 'styles' => [ 'class' => ImageStyleBehavior::className(), 'path' => '@webroot/uploads/styles', 'url' => '@web/uploads/styles', 'attribute' => 'uri', 'styles' => [ 'big' => [$this, 'styleBig'], //can be any valid callable 'small' => [$this, 'styleSmall'] ] ] ]; } /** * @return \Imagine\Image\ManipulatorInterface */ public function styleBig() { return Image::thumbnail($this->filePath, 814, 458)->save($this->style('big')->path); } }
Usage
$file = ImageFile::findOne($id); echo $file->style('big')->url;
统计信息
- 总下载量: 45
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2015-03-07