drishu/yii2-imagecache

the better image cache

Installs: 55

Dependents: 0

Suggesters: 0

Security: 0

Stars: 2

Watchers: 2

Forks: 0

Open Issues: 0

Type:yii2-extension

1.0.6 2015-07-14 20:23 UTC

This package is auto-updated.

Last update: 2024-04-06 15:54:41 UTC


README

the better image cache

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist drishu/yii2-imagecache "*"

or add

"drishu/yii2-imagecache": "*"

to the require section of your composer.json file.

imageCache component config

You should add imageCache component in your application configuration :

$config = [
    'components' => [
      ...
      'imagecache' => [
        'class' => 'drishu\yii2imagecache\ImageCache',
        // the below paths depend very much on your image upload setup
        'sourcePath' => Yii::getAlias('@base'), // base path to your uploads dir
        'cachePath' => '/data', // relative path to your uploads dir
      ],
      ...
    ],
];

Usage

In your view, controller, component, etc. just call :

<?= Html::img(Yii::$app->imagecache->get($image->path, '0x160'))?>```