sfImageTransformExtraPlugin - 0.9.1
Christian Schaefer <firstname.lastname@example.org>
You are currently browsing
the website for symfony 1
Christian Schaefer <email@example.com>
Utilising the fantastic sfImageTransformPlugin this plugin provides all means to configure any set of thumbnail formats with all possible transformations in a YAML file. All these configured settings can be applied to any kind of source image using a nice URL schema.
|Christian Schaefer <firstname.lastname@example.org>||lead||yl.laci <<ta>> refeac|
Copyright (c) 2010 Christian Schaefer
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
$ php symfony --color transforms:check-caching frontend
Run this task to check if your settings allow the thumbnail caching to work properly.
>> no script name sf_no_script_name is set to true.
>> caching sf_cache is set to true.
>> route 'sf_image' exists.
>> route Route 'sf_image' points to '/thumbnails/in/some/deeper/path/'.
>> route The absolute path for this is '/path/to/your/project/web/thumbnails/in/some/deeper/path/'.
>> cache dir Path '/thumbnails/in/some/deeper/path' does not exist. Let's move one level up.
>> cache dir Path '/thumbnails/in/some/deeper' does not exist. Let's move one level up.
>> cache dir Path '/thumbnails/in/some' does not exist. Let's move one level up.
>> cache dir Path '/thumbnails/in' does not exist. Let's move one level up.
>> cache dir Path '/path/to/your/project/sfiteptask/web/thumbnails' exists.
>> cache dir Path '/path/to/your/project/sfiteptask/web/thumbnails' is a directory.
>> cache dir Path '/path/to/your/project/sfiteptask/web/thumbnails' is writable.
Please note that this check is testing priviledges for your current user account.
If your web server is running from a different user account (as it should) the result could be different.
Everything seems to be alright. If it still does not work it's probably a permissions problem.
This is a bugfix release. Remote image sources depending on their binary structure might not have been able to detect the mime type of. This was caused by getimagesize() seeking when mime information could not be read from the first chunk of data.
PLEASE NOTE! In this release there is a bugfix of the autoboxing feature which requires you to change your thumbnailing.yml if you use transformations like overlay or alphamask. In this case you have to prefix the overlay and mask parameters with "sfImage|". See http://trac.symfony-project.org/changeset/29292 for an example.
On a website you ususally find lots of images and a set of formats. Say a user avatar is always
80x80 PNG while a homepage top image is always
320x140 JPG with round corners. As it is far too costly to prepare all these different formats by hand there are automated ways to generate them from source images uploaded by a user. One of the best tools for this in the symfony world is the sfImageTransformPlugin which enables you to perform many sophisticated transformations on your images such as resizing, color manipulation, overlays and more.
Using such an automatism means you have to write code and perform all necessary transformation on upload, no matter if the generated files are ever requested. It also means that design changes that also change the formats lead to change of business logic rather than just templates.
This is where sfImageTransformExtraPlugin springs to action as it provides a way to configure formats with multiple transformations. In your templates you only refer to the format by name which results in an SEO friendly image URL. The image itself will be generated on first request and (in production environments) written to the filesystem.
Here are some of the key features:
To install the plugin for a symfony project, the usual process is to use the symfony command line:
symfony plugin:install sfImageTransformPlugin
Alternatively, if you don't have PEAR installed, you can download the latest package attached to this plugin's wiki page and extract it under your project's
Clear the cache to enable the autoloading to find the new classes:
php symfony cc
Note: The plugin requires sfImageTransformPlugin to be installed as well. The dependencies described there apply as well.