Yii 2.0: yii2-imgcache

Image effect, thumb and cache extension for Yii2
1 follower

Latest Stable Version Total Downloads License

About

The lireincore/imgcache integration for Yii2 framework. Similar to imgcache in Drupal. Supports GD, Imagick and Gmagick.

Requirements

Install

Add the "lireincore/yii2-imgcache": "dev-master" package to your require section in the composer.json file

or

$ composer require lireincore/yii2-imgcache dev-master

Usage

To use this extension, you need create the imgcache.php file in your config folder and add this example code:

<?php
 
return [
    'srcdir' => '@app/files/uploads',
    'destdir' => '@webroot/thumbs',
    'webdir' => '@webroot',
    'baseurl' => '@web',
    //....
    'presets' => [
        'origin' => [
            'effects' => [
                //add the effects you need
                //....
            ],
        ],
    ],
];

See lireincore/imgcache README.md for more information about the available effects and other config options.

Also add the following code in your Yii2 application configuration:

$config = [
    //....
    'components' => [
        //....
        'imgcache'=> [
            'class' => 'LireinCore\Yii2ImgCache\ImgCache',
            'config' => require(__DIR__ . '/imgcache.php'),
        ],
    ],
];

Use in your code:

//get thumb url for image '{srcdir}/blog/image.jpg' (preset 'origin')
$url = \Yii::$app->imgcache->url('origin', 'blog/image.jpg');

See lireincore/imgcache README.md for more information about the available functions.

Resources

License

The MIT License (MIT). Please see License File for more information.

Be the first person to leave a comment

Please to leave your comment.

Create extension
Downloads
No downloadable files yet