black-lamp/yii2-imagable

本包最新版本(v1.3)没有提供许可证信息。

yii2 图像保存扩展

安装: 803

依赖: 6

建议者: 0

安全: 0

星星: 1

关注者: 5

分支: 1

开放问题: 1

类型:yii2-extension

v1.3 2019-06-22 11:22 UTC

This package is not auto-updated.

Last update: 2024-09-14 17:43:03 UTC


README

##安装

php composer.phar install black-lamp/yii2-imagable

或添加

"black-lamp/yii2-imagable": "*"

到您的 composer.json 的 require 部分。#配置 在扩展安装后,您需要设置 imagable 应用组件

'imagable' => [
    'class' => 'bl\imagable\Imagable',
    'imageClass' => 'bl\imagable\instances\CreateImageImagine',
    'categories' => [
        'origin' => false,
        'category' => [
            'galery' => [
                'origin' => true,
            ],
            'galery/more' => [
                'origin' => false,
            ],
            'avatars' => [
                'size' => [
                    'big' => [
                        'width' => 1000,
                        'height' => 500,
                    ]
                ]
            ]
        ]
    ]
    ...

##使用

###创建图像

$imageName = \Yii::$app->imagable->create('avatars', 'pathToImage');
// Or
$imageName = \Yii::$app->imagable->createMultiply(['avatars', 'galery/more'], 'pathToImage');

###获取图像

$fullPathToImage = \Yii::$app->imagable->get('avatars', 'big', $imageName);

###删除图像

$isDeleted = \Yii::$app->imagable->delete('avatars', $imageName);

###数据提供者

//To action
/** @var Imagable $image */
$imagable = \Yii::$app->imagable;
$imagable->dataProvider = [
    'key' => $data
];
//...

//To class
class ImageClass extends Object implements CreateImageInterface
{
    public $dataProvider;
    
    public function init()
    {
        parent::init(); // TODO: Change the autogenerated stub
        echo $this->dataProvider['key'];
    }
    
    //...
}