yiimaker/yii2-imagable

There is no license information available for the latest version (1.0.1) of this package.

Image saving extension for yii2

Installs: 17

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 3

Forks: 0

Open Issues: 4

Type:bsd-3-clause

1.0.1 2017-01-09 12:47 UTC

This package is auto-updated.

Last update: 2024-11-14 03:34:00 UTC


README

#Instalation

php composer.phar require yiimaker/yii2-imagable

or add

"yiimaker/yii2-imagable": "*"

to the require section of your composer.json. #Confiugation After extension is installed you need to setup imagable application component:

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

#Usage

###Create image

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

###Get Image

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

###Delete Image

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

###Data provider

//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'];
    }
    
    //...
}