This plugin provide Imagine (https://github.com/avalanche123/Imagine) support for symfony 1.3/1.4. Inspired from AvalancheImagineBundle for Symfony2
This plugin is functional, but still experimental, so, it is only available on Github for the moment. The stable version will be available by the symfony plugin manager.
This plugin is designed to works with the fwClassLoaderPlugin, see https://github.com/frequence-web/fwClassLoaderPlugin
You can use fwImaginePlugin without the fwClassLoaderPlugin, but you need to implement an way to autoload Imagine classes (namespaced php5.3 classes)
git clone https://github.com/avalanche123/Imagine.git lib/vendor/imagine
or
git submodule add https://github.com/avalanche123/Imagine.git lib/vendor/imagine
git clone https://github.com/frequence-web/fwImaginePlugin.git plugins/fwImaginePlugin
or
git submodule add https://github.com/frequence-web/fwImaginePlugin.git plugins/fwImaginePlugin
Edit your config/ProjectConfiguration.class.php file and add this line in the setup method
$this->enablePlugins('fwImaginePlugin');
Install the Symfony2 ClassLoader component and the fwClassLoaderPlugin (Optional if you use your own autoload)
git clone https://github.com/symfony/ClassLoader.git lib/vendor/symfony2/src/Symfony/ClassLoader
./symfony plugin:install fwClassLoader
Edit your config/ProjectConfiguration.class.php file and add this line in the setup method
$this->enablePlugins('fwClassLoaderPlugin');
Edit your settings.yml file and add the fwImagine module
all:
settings:
...
enabled_modules: [fwImagine]
Create a fw_imagine.yml file inside config/ or apps/*/config/ dir and define your filters :
all:
filters:
list_thumbnail:
type: thumbnail
options: { size: [120, 90], mode: inset }
rotate90:
type: rotate
options: { angle: 90, color: 'FFFFFF', alpha: 0 }
You can now use your filters into your templates
<?php use_helper('imagine'); ?>
<?php echo imagine_image('/web/path/to/image', 'list_thumbnail') ?>
<?php use_helper('imagine'); ?>
<?php $path = imagine_filter('/web/path/to/image', 'list_thumbnail'); ?>
thumbnail, rotate
<?php
use Imagine\Image\Box;
use Imagine\Image\ManipulatorInterface;
use Imagine\Filter\Basic\Thumbnail;
class fwImagineThumbnailLoader implements fwImagineLoader
{
public function load(array $options)
{
$mode = $options['mode'] === 'inset' ?
ManipulatorInterface::THUMBNAIL_INSET :
ManipulatorInterface::THUMBNAIL_OUTBOUND;
list($width, $height) = $options['size'];
return new Thumbnail(new Box($width, $height), $mode);
}
}
$this->dispatcher->connect('fw_imagine.get_loaders', function(sfEvent $event) {
$event->getSubject()->addLoader(new fwImagineThumbnailLoader());
});
- Unit tests
- Functional tests