PHPackages                             iutbay/yii2-imagecache - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Caching](/categories/caching)
4. /
5. iutbay/yii2-imagecache

AbandonedArchivedYii2-extension[Caching](/categories/caching)

iutbay/yii2-imagecache
======================

ImageCache for Yii2

0.2(11y ago)2021.2k↓50%12[2 issues](https://github.com/iutbay/yii2-imagecache/issues)[2 PRs](https://github.com/iutbay/yii2-imagecache/pulls)PHP

Since Dec 2Pushed 4y ago2 watchersCompare

[ Source](https://github.com/iutbay/yii2-imagecache)[ Packagist](https://packagist.org/packages/iutbay/yii2-imagecache)[ Docs](https://github.com/iutbay/yii2-imagecache)[ RSS](/packages/iutbay-yii2-imagecache/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (1)Versions (3)Used By (0)

ImageCache for Yii2
===================

[](#imagecache-for-yii2)

Like the Image module in Drupal, this extension will resize your images on demand :-). If a thumb doesn't exist, the web server's rewrite rules will pass the request to Yii which in turn hands it off to ImageCache to dynamically generate the file.

WIP...

Features
--------

[](#features)

- image resize on demand
- text watermark
- image watermark

Installation
------------

[](#installation)

The preferred way to install this helper is through [composer](http://getcomposer.org/download/).

Either run

```
php composer.phar require "iutbay/yii2-imagecache" "*"

```

or add

```
"iutbay/yii2-imagecache" : "*"
```

to the require section of your application's `composer.json` file.

Configuration
-------------

[](#configuration)

You should :

- Add `ThumbAction` in one of your controller.
- Modify your application configuration :
    - add *imageCache* component,
    - add url rule to handle request to missing thumbs.

### Add *ThumbAction*

[](#add-thumbaction)

You need to add `ThumbAction` in one of your controller so that imageCache can handle requests to missing thumbs and create them on demand. You could use `site` controller :

```
class SiteController extends Controller
{
  ...
  public function actions()
  {
      return [
        ...
        'thumb' => 'iutbay\yii2imagecache\ThumbAction',
        ...
      ];
  }
  ...
}
```

### *imageCache* component config

[](#imagecache-component-config)

You should add *imageCache* component in your application configuration :

```
$config = [
    'components' => [
      ...
      'imageCache' => [
        'class' => 'iutbay\yii2imagecache\ImageCache',
        'sourcePath' => '@app/web/images',
        'sourceUrl' => '@web/images',
        //'thumbsPath' => '@app/web/thumbs',
        //'thumbsUrl' => '@web/thumbs',
        //'sizes' => [
        //    'thumb' => [150, 150],
        //    'medium' => [300, 300],
        //    'large' => [600, 600],
        //],
      ],
      ...
    ],
];
```

### *urlManager* config

[](#urlmanager-config)

> You should enable pretty urls :

>

You should modify your *urlManager* configuration :

```
$config = [
    'components' => [
      ...
      'urlManager' => [
        'enablePrettyUrl' => true,
        'showScriptName' => false,
        'rules' => [
          ...
          'thumbs/' => 'site/thumb',
          ...
        ],
      ],
      ...
    ],
];
```

How to use
----------

[](#how-to-use)

```
