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

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

kaliel/cakephp-image
====================

CakePHP 4.0 Image upload behavior

2.0.0(6y ago)023MITPHPPHP &gt;=7.2

Since May 14Pushed 6y agoCompare

[ Source](https://github.com/maxchene/cakephp-image)[ Packagist](https://packagist.org/packages/kaliel/cakephp-image)[ Docs](https://github.com/josbeir/Image)[ RSS](/packages/kaliel-cakephp-image/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (4)Versions (11)Used By (0)

Cake 4 Image field behavior
===========================

[](#cake-4-image-field-behavior)

[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.txt)[![Build Status](https://camo.githubusercontent.com/5054052c32bcb064bd273c83e007b05b9601f595377d85f06aab15e039377995/68747470733a2f2f7472617669732d63692e6f72672f6a6f73626569722f63616b657068702d696d6167652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/josbeir/cakephp-image)

Image behavior that works much like Cake's built in Translate Behavior by adding fields with image data to every entity the table returns.

- Uploads can be either $\_FILE based or just a string containing path. 'copy' or 'move\_uploaded\_file' is used accordingly.
- Validating should be done by cake's nice validation options and is therefore not included in the behavior itself.
- Image presets are generated using [Intervention/Image](https://github.com/Intervention/image). See the [documentation](http://image.intervention.io/) page.

Notes
-----

[](#notes)

The behavior is very much a work in progress and should not be considered stable in any way.

Configuration parameters
------------------------

[](#configuration-parameters)

- **fields**: Fields used for images, should be the name of the field as key and the type as value (many, one)
- **presets**: Array of presets containing a list of Intervention/Image methods and their parameters, can also be a callable function with the image object passed
- **path**: The base path where the uploaded images should be stored
- **table**: The table name of for storing the image data (see Config/Schema/images.sql)
- **manager**: Settings for Intervention\\Image\\ImageManager (defaults to driver : imagick)

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

[](#installation)

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

```
php composer.phar require kaliel/image

```

Load the plugin by adding the following statement in your project's `src/Application.php`:

```
public function bootstrap(): void
{
    parent::bootstrap();

    $this->addPlugin('Image');
}
```

Init the database table by using cakephp's migrations

```
bin/cake migrations migrate -p Image

```

Enable the image behavior by adding it to the Table's initialize hook

```
public function initialize(array $config)
{
    $this->addBehavior('Image.Image', [
        'path' => WWW_ROOT . 'assets',
        'fields' => [
            'images' => 'many',
            'main' => 'one'
        ],
    ]);
}
```

Image presets
-------------

[](#image-presets)

Image manipulation is handled by [Intervention/Image](https://github.com/Intervention/image) and configuring presets is pretty straightforward. In the example below the preset 'overview' is generated by looping trough various Intervention/Image helper functions

```
$this->addBehavior('Image.Image', [
	'path' => WWW_ROOT . 'assets',
	'presets' => [
		'overview' => [
			'resize' => [ 200, 200 ], // $image->resize(200, 200);
			'crop' => [ 150, 150] // $image->crop(150,150);
			'canvas' => function($image) {
			 	// you can use callback functions for more advanced stuff
				// do some fancy stuff here

				return $image;
			},
		]
	],
	'fields' => [
		'image' => 'one'
	],
]);
```

Helper
------

[](#helper)

I've included a basic helper to render the images in your templates.

```
$this->Image->render($entity->field); // Original image
$this->Image->render($entity->field, [ 'preset' => 'presetName' ]); // Preset
$this->Image->render($entity->field, [ 'preset' => 'presetName', 'alt' => 'Cool image' ]); // Preset + image attributes
$this->Image->url($entity->field, 'presetName'); // Returns the image path with an optional preset argument
```

Shell
-----

[](#shell)

Simple shell to re-generate all presets for given model

```
bin/cake image

```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity64

Established project with proven stability

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.

###  Release Activity

Cadence

Every ~219 days

Recently: every ~411 days

Total

9

Last Release

2261d ago

Major Versions

v0.2 → v1.02015-05-15

v1.50 → 2.0.02020-03-05

PHP version history (3 changes)v0.2PHP &gt;=5.4

v1.50PHP &gt;=5.6

2.0.0PHP &gt;=7.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/9c1a15529bbcb1a1412a5c88d8fdf6175cc747cde24f17b2809caf92d502557b?d=identicon)[maxchene](/maintainers/maxchene)

---

Tags

imagecakephp

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[league/glide

Wonderfully easy on-demand image manipulation library with an HTTP based API.

2.6k51.2M116](/packages/league-glide)[intervention/image-laravel

Laravel Integration of Intervention Image

1496.5M102](/packages/intervention-image-laravel)[bkwld/croppa

Image thumbnail creation through specially formatted URLs for Laravel

510496.0k23](/packages/bkwld-croppa)[lasserafn/php-initial-avatar-generator

A package to generate avatars with initials for PHP

4374.2M13](/packages/lasserafn-php-initial-avatar-generator)[admad/cakephp-glide

CakePHP plugin for using Glide image manipulation library.

34160.7k1](/packages/admad-cakephp-glide)[ctessier/nova-advanced-image-field

An advanced image field for Nova with cropping and resizing.

103548.4k1](/packages/ctessier-nova-advanced-image-field)

PHPackages © 2026

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