PHP code example of happyproff / yii-easyimages

1. Go to this page and download the library: Download happyproff/yii-easyimages library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

happyproff / yii-easyimages example snippets


'components' => [
    ...,
    'easyImages' => [
        'class' => 'happyproff\YiiEasyImages\EasyImages',
    ],
    ...
]

class MCategory extends ActiveRecord {
    use happyproff\YiiEasyImages\TEasyImage;
    ...

public function beforeSave () {
    if (!parent::beforeSave()) return false;

    if (method_exists($this, 'handleImages')) {
        $this->handleImages();
    }

    return true;
}

public function images () {
    return [
        'image' => [
            self::IMAGE_ORIGINAL => ['width' => 1920, 'height' => 1080, 'enabled' => false],
            self::IMAGE_FULL => ['width' => 960, 'height' => 720, 'quality' => 100],
            self::IMAGE_LIST => ['width' => 146, 'height' => 160, 'inset' => false,],
            self::IMAGE_ITEM => ['width' => 300, 'height' => 999],
        ],
    ];
}