Download the PHP package kaliel/cakephp-image without Composer
On this page you can find all versions of the php package kaliel/cakephp-image. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download kaliel/cakephp-image
More information about kaliel/cakephp-image
Files in kaliel/cakephp-image
Package cakephp-image
Short Description CakePHP 4.0 Image upload behavior
License MIT
Homepage https://github.com/josbeir/Image
Informations about the package cakephp-image
Cake 4 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. See the documentation page.
Notes
The behavior is very much a work in progress and should not be considered stable in any way.
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
You can install this plugin into your CakePHP application using composer:
Load the plugin by adding the following statement in your project's
src/Application.php
:
Init the database table by using cakephp's migrations
Enable the image behavior by adding it to the Table's initialize hook
Image presets
Image manipulation is handled by 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
Helper
I've included a basic helper to render the images in your templates.
Shell
Simple shell to re-generate all presets for given model