2017 © Pedro Peláez
 

yii2-extension yii2-image-style-behavior

Yii 2 image styles generation behavior

image

artkost/yii2-image-style-behavior

Yii 2 image styles generation behavior

  • Thursday, August 27, 2015
  • by JiLiZART
  • Repository
  • 1 Watchers
  • 3 Stars
  • 36 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Image style generate behavior for Yii 2

Create sets of styles for your images, (*1)

Installation

The preferred way to install this extension is through composer., (*2)

Either run, (*3)

$ composer require artkost/yii2-image-style-behavior

or add, (*4)

"artkost/yii2-image-style-behavior": "*"

to the require section of your composer.json file., (*5)

Configuring

Configure model as follows, (*6)

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;

The Versions

27/08 2015

dev-master

9999999-dev

Yii 2 image styles generation behavior

  Sources   Download

BSD-3-Clause

The Requires

 

by Nikolay Kostyurin

style yii behavior image

01/04 2015

dev-develop

dev-develop

Yii 2 image styles generation behavior

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Nikolay Kostyurin

style yii behavior image

08/03 2015

0.1

0.1.0.0

Yii 2 image styles generation behavior

  Sources   Download

BSD-3-Clause

The Requires

 

by Nikolay Kostyurin

style yii behavior image