PHPackages                             karolak/cakephp-image - 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. karolak/cakephp-image

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

karolak/cakephp-image
=====================

Image plugin for CakePHP 3.

132[2 issues](https://github.com/karolak/cakephp-image/issues)PHP

Since Apr 9Pushed 11y ago1 watchersCompare

[ Source](https://github.com/karolak/cakephp-image)[ Packagist](https://packagist.org/packages/karolak/cakephp-image)[ RSS](/packages/karolak-cakephp-image/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Image plugin for CakePHP 3
==========================

[](#image-plugin-for-cakephp-3)

Plugin for fast and easy handling image uploads in CakePHP.

Image presets are generated using [WideImage](https://github.com/smottt/WideImage). See the sourceforge [documentation](http://wideimage.sourceforge.net/) page.

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 karolak/cakephp-image

```

or manually add this line to your "require" key in composer.json file:

```
"require": {
    ...
    "karolak/cakephp-image": "dev-master"
}
```

and run in console:

```
$ composer update

```

Next in your bootstrap.php file add line (to enable plugin in your app):

```
Plugin::load('Image', ['bootstrap' => false, 'routes' => false]);
```

Database preparation
--------------------

[](#database-preparation)

To create table "images" in your database for storing informations about uploaded images, run this command:

```
$ bin/cake migrations migrate -p Image

```

Behavior configuration parameters
---------------------------------

[](#behavior-configuration-parameters)

- **fields**: Input fields used for images, should be the name of the file input field as key and the type as value (many, one)
- **presets**: Array of presets containing a list of WideImage methods and their parameters
- **path**: The base path where the uploaded images should be stored
- **quality**: Image quality for all presets (integer from 1 to 100)
- **table**: Table name for storing informactions about images.

Usage
-----

[](#usage)

Before you add a file upload field to a form, you must first make sure that the form enctype is set to “multipart/form-data”:

```
echo $this->Form->create($document, ['enctype' => 'multipart/form-data']);
// OR
echo $this->Form->create($document, ['type' => 'file']);
```

Next add one or more file inputs:

```
echo $this->Form->input('photos', ['type' => 'file']);
```

Now you have to configure behavior in your table class. For example, add this to your initialize method:

```
public function initialize(array $config)
{
  $this->addBehavior('Image.Image', [
      'path' => Configure::read('App.wwwRoot').Configure::read('App.imageBaseUrl').'uploads',
      'presets' => [
          'small' => [
              'resize' => [200, 200, 'outside', 'any'],
              'crop' => ['center', 'center', 200, 200]
          ],
          'big' => [
              'resize' => [1000, 1000, 'inside', 'any']
          ]
      ],
      'fields' => [
          'photos' => 'many'
      ],
      'quality' => 80
  ]);
}
```

Validation
----------

[](#validation)

To check uploaded images use Cake's standard validation methods (in 3.0 version they add some new file validation rules).

Receiving images
----------------

[](#receiving-images)

```
$document = $this->Documents->get($id, ['contain' => ['Images_DocumentsPhotos']]);
```

This example assume that your table is called **Documents** and form field name used to upload images was **photos**.

Helper
------

[](#helper)

You can use helper to show images from presets. Just add this code to AppView initialize method:

```
public function initialize()
{
    if(Plugin::loaded('Image')) {
        $this->loadHelper('Image.Image');
    }
}
```

Now to render img tag with image from preset use:

```
echo $this->Image->render($image); // original file
echo $this->Image->render($image, ['preset' => 'small']); // image file from "small" preset
echo $this->Image->render($image, ['preset' => 'big', 'alt' => 'Cool image']); // image file from "big" preset + img attributes
```

Or you can just get image url:

```
echo $this->Image->url($image);
```

TODO
----

[](#todo)

- Extend documentation
- Shell script to regenerate all preset images
- Write tests

###  Health Score

16

—

LowBetter than 5% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/2c3da892874c330d8ee681c08f4ada3c22157bb9c3ac90623cc9356fdace4f00?d=identicon)[karolak](/maintainers/karolak)

---

Top Contributors

[![karolak](https://avatars.githubusercontent.com/u/3680710?v=4)](https://github.com/karolak "karolak (2 commits)")

### Embed Badge

![Health badge](/badges/karolak-cakephp-image/health.svg)

```
[![Health](https://phpackages.com/badges/karolak-cakephp-image/health.svg)](https://phpackages.com/packages/karolak-cakephp-image)
```

###  Alternatives

[milon/barcode

Barcode generator like Qr Code, PDF417, C39, C39+, C39E, C39E+, C93, S25, S25+, I25, I25+, C128, C128A, C128B, C128C, 2-Digits UPC-Based Extention, 5-Digits UPC-Based Extention, EAN 8, EAN 13, UPC-A, UPC-E, MSI (Variation of Plessey code)

1.5k13.3M39](/packages/milon-barcode)[bkwld/croppa

Image thumbnail creation through specially formatted URLs for Laravel

510496.0k23](/packages/bkwld-croppa)[goat1000/svggraph

Generates SVG graphs

132849.6k3](/packages/goat1000-svggraph)[cohensive/embed

Media Embed (for Laravel or as a standalone).

120370.4k](/packages/cohensive-embed)[netresearch/rte-ckeditor-image

Image support in CKEditor for the TYPO3 ecosystem - by Netresearch

63991.3k4](/packages/netresearch-rte-ckeditor-image)[humanmade/tachyon-plugin

Rewrites WordPress image URLs to use Tachyon

87338.5k2](/packages/humanmade-tachyon-plugin)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
