PHPackages                             xavier83ar/image-presenter - 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. [Image &amp; Media](/categories/media)
4. /
5. xavier83ar/image-presenter

ActiveCakephp-plugin[Image &amp; Media](/categories/media)

xavier83ar/image-presenter
==========================

A CakePHP plugin for creating thumbnails and image variants on the fly

v1.0.7(10y ago)141[2 issues](https://github.com/xavier83ar/image-presenter/issues)MITPHPPHP &gt;=5.4.16

Since Feb 18Pushed 10y ago1 watchersCompare

[ Source](https://github.com/xavier83ar/image-presenter)[ Packagist](https://packagist.org/packages/xavier83ar/image-presenter)[ RSS](/packages/xavier83ar-image-presenter/feed)WikiDiscussions master Synced 3w ago

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

ImagePresenter plugin for CakePHP
=================================

[](#imagepresenter-plugin-for-cakephp)

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

[](#installation)

You can install this plugin into your CakePHP application using [composer](http://getcomposer.org).

The recommended way to install composer packages is:

```
composer require xavier83ar/image-presenter

```

Usage
-----

[](#usage)

Load the plugin

```
Plugin::load('ImagePresenter', ['routes' => true]);
```

Configure your variants...

```
'ImagePresenter' => [
    'variants' => [
        'thumbnail' => [
            'size' => [350, 250],
            'mode' => ImageInterface::THUMBNAIL_OUTBOUND,
            'filter' => ImageInterface::FILTER_LANCZOS
        ],
        'mini' => [
            'operation' => 'thumbnail',
            'size' => [120, 120],
            'mode' => ImageInterface::THUMBNAIL_INSET,
        ],
        'other' => [
            'operation' => function (ImageInterface $imagine) {
                return $imagine->resize(new Box(400, 300))->rotate(90);
            }
        ],
        'amazing' => [
            'operation' => function (ImageInterface $imagine) {
                return $imagine
                    ->resize(new Box(600, 320))
                    ->effects()->grayscale()->blur(5);
            }
        ],
    ],
]
```

Any variant which its name starts with "thumbnail" will use thumbnail operation mode. Right now there two operation modes: thumbnail, which sets up a `ImageInterface::thumbnail()` operation, and closure mode, which allows you to pass a closure which receive an `ImageInterface` to play with.

This helpers uses imagine/imagine package for image manipulation operations, see for more information.

### Showing up images

[](#showing-up-images)

Finally load and use ImageHelper

```
class AppView extends View
{
    public function initialize()
    {
        $this->loadHelper('ImagePresenter.Image');
    }
}
```

On your templates

```
