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

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

josbeir/image
=============

CakePHP 3.0 Image upload behavior

v1.50(8y ago)203.5k12[2 issues](https://github.com/josbeir/Image/issues)[1 PRs](https://github.com/josbeir/Image/pulls)MITPHPPHP &gt;=5.6CI failing

Since May 14Pushed 5y ago4 watchersCompare

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

READMEChangelog (6)Dependencies (5)Versions (9)Used By (0)

Cake3 Image field behavior [![Build Status](https://camo.githubusercontent.com/5054052c32bcb064bd273c83e007b05b9601f595377d85f06aab15e039377995/68747470733a2f2f7472617669732d63692e6f72672f6a6f73626569722f63616b657068702d696d6167652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/josbeir/cakephp-image)
=========================================================================================================================================================================================================================================================================================================================

[](#cake3-image-field-behavior-)

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)

### Usage

[](#usage)

Install using composer

```
"require": {
	"josbeir/image": "~1.0"
}
```

And run `php composer.phar install`

Enable the plugin by adding it to bootstrap.php

```
Plugin::load('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

35

—

LowBetter than 77% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity32

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity63

Established project with proven stability

 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.

###  Release Activity

Cadence

Every ~161 days

Recently: every ~269 days

Total

8

Last Release

2942d ago

Major Versions

v0.2 → v1.02015-05-15

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

v1.50PHP &gt;=5.6

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/26058?v=4)[Jasper Smet](/maintainers/josbeir)[@josbeir](https://github.com/josbeir)

---

Top Contributors

[![josbeir](https://avatars.githubusercontent.com/u/26058?v=4)](https://github.com/josbeir "josbeir (56 commits)")

---

Tags

imagecakephp

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[league/glide

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

2.6k53.3M146](/packages/league-glide)[intervention/image-laravel

Laravel Integration of Intervention Image

1588.9M186](/packages/intervention-image-laravel)[cakephp/bake

Bake plugin for CakePHP

11212.0M202](/packages/cakephp-bake)[bkwld/croppa

Image thumbnail creation through specially formatted URLs for Laravel

506516.3k29](/packages/bkwld-croppa)[dereuromark/cakephp-queue

The Queue plugin for CakePHP provides deferred task execution.

308954.9k25](/packages/dereuromark-cakephp-queue)[dereuromark/cakephp-ide-helper

CakePHP IdeHelper Plugin to improve auto-completion

1882.3M44](/packages/dereuromark-cakephp-ide-helper)

PHPackages © 2026

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