yii2-imgcache Image effect, thumb and cache extension for Yii2

  1. About
  2. Requirements
  3. Install
  4. Usage
  5. Resources
  6. License

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.

0 0
1 follower
0 downloads
Yii Version: 2.0
License: MIT
Category: Caching
Developed by: lireincore
Created on: Mar 20, 2017
Last updated: a year ago

Related Extensions