This plugin allows you to effortlessly add image editing capabilities to your admin generator backend. You'll be able to add images to your models and be presented with the awesome Jcrop (http://deepliquid.com/content/Jcrop.html) jQuery plugin.

Features

The plugin already has a few very useful features

Create as many different sized crops of each of your image fields as you like

Add any amount of coloured padding around the croppable image

Fix the aspect ratio of the cropper to add consistency to your images' dimensions

Developers

License

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

Join this plugin team

Changelog for release 1.0.1 - 12/10/2009

Other releases

Release 1.0.7 - 20/01/2010

Release 1.0.6 - 12/01/2010

Updated release to reflect compatibility with symfony 1.4

Release 1.0.5 - 17/11/2009

Fix to get rid of warnings when using PHP 5.3.x as reported by Gunther Konig

Release 1.0.4 - 11/11/2009

Made field ids non-camelcase
Changed to take form rather than form_options as option since form has getOption method anyway
Changed embedded form prefix from 'embedded' to 'embedded_'
Using the widgetschema's name format instead of the model's table name for the id stub in order to play nicely with inheritance
Added detection and use of sfJSLibManager::addLib('jcrop') if found (from sfJSLibManagerPlugin)

Release 1.0.3 - 16/10/2009

Added getImageTag public method for ease of use on frontend
Renamed 'model_object' option to 'invoker'

Release 1.0.2 - 13/10/2009

Release 1.0.1 - 12/10/2009

sfDoctrineJCroppablePlugin

The plugin will also automatically create and save the cropped images for you,
in sizes you can configure.

Installation

To install the plugin for a symfony project, the usual process is to use the
symfony command line:

php symfony plugin:install --install-deps sfDoctrineJCroppablePlugin

sfDoctrineJCroppablePlugin depends on the excellent sfImageTransformPlugin, but
until I can figure out how to specify that dependancy in the package then you'll
have to install it yourself (it's getting late!)

php symfony plugin:install sfImageTransformPlugin

If for some reason this fails (eg you're running symfony 1.3) then you can
manually download the tgz file from

Symfony 1.2 & Doctrine 1.0

If you're using symfony 1.2 which comes with doctrine 1.0 this plugin will not
be able to delete the old versions of it's images when it creates new ones. This
is because we've not been able to find a way of getting the old filename.
Upgrading to doctrine 1.1 fixes this and is a reasonably straightforward
exorcise. There is a good guide here:

http://www.brandonturner.net/blog/2009/05/doctrine11-with-symfony12/

Symfony 1.3 comes with doctrine 1.2 and so this is not an issue.

Usage

You'll first want to edit your config/doctrine/schema.yml to add the behaviour
to one of your models:

If you haven't aleady done so let's create an admin module for our person model:

php symfony doctrine:generate-admin backend Person --module=person

The plugin also depends on the jquery & jcrop libraries, so you must download
them (http://deepliquid.com/content/Jcrop.html) and place the two js files
(jquery.Jcrop.min.js & jquery.min.js) in web/js, and the css file
(jquery.Jcrop.css) in web/css:

Now we need to tell our module's view to include them. We can do this
specifically for our module by editing
apps/backend/modules/person/config/view.yml, or for the whole application by
editing apps/backend/config/view.yml:

We're almost finished now! Just two things left to do. First we have to
configure the widget & validator for our jcroppable image field. Add the
following calls to configure the widgets & validators to the form's confgure
function (lib/form/doctrine/PersonForm.class.php):

directory - overrides the default web/uploads/images/Person to instead be
web/uploads/people

padding - adds padding to the image, of the specified color, using either a
'percent' or 'pixels' value

ratio - fixes the aspect ratio of the cropper and therefore the generated
cropped images

sizes - allows you to specify any number of different sized images to be
created. You specify the width ad the height will be calculated using the
ratio if there is one, otherwise it will be variable according to the
selected crop. The default sizes are thumb (width 120px) &
main (width 360px)