Repository that contains a resizer for symfony2, used to cache thumbnail of image.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Ulrich Van Den Hekke aa8fd2a22d feat(symfony): Update the version of symfony 1 year ago
Cache Add the resized image in the cache. 6 years ago
Controller Add pagespeed optimisation 1 year ago
DependencyInjection Bug correction and add filesystem and apc cache. 6 years ago
Extensions feat(symfony): Update the version of symfony 1 year ago
Image Correction of the image resize bundle 1 year ago
Resources/config feat(symfony): Update the version of symfony 1 year ago
Templating/Helper Add pagespeed optimisation 1 year ago
Tests/Templating/Helper modifications needed for latest upstream Symfony version 8 years ago
ImageResizerBundle.php modifications needed for latest upstream Symfony version 8 years ago
README.markdown Add the resized image in the cache. 6 years ago
composer.json feat(symfony): Update the version of symfony 1 year ago

README.markdown

Provides “on the fly” image resizement using Imagick, CURL & Memcached (by default).

Installation

checkout the bundle to your src/Bundle dir

git submodule add git://github.com/nresni/ImageResizerBundle.git src/Bundle/Adenclassifieds/ImageResizerBundle

Initalize the bundle into your application Kernel

// app/AppKernel.php
public function registerBundles()
{
    return array(
        //..
        new Adenclassifieds\ImageResizerBundle\ImageResizerBundle(),
        //..
    );
}

Setup file compression in your config.yml

image_resizer:
    # the cache adapter
    cache:
      class: memcache # accepted are : memcache, mongo
      dsn: localhost
      port: 11211
      # for mongo only
      database: imageresizer
      collection: files

    # available functions (activated by default)
    functions : [cropCenter, adaptive, homothetic]

    # named sizes
    sizes:
        small: [32, 32] # width, height (default)

    # where to find the images (default to /tmp)
    base_directory: /path/to/images

For Mongodb based cache only :

please run the following command to create the database and collection with correct indexes

./console imageresizer:initialize:mongo

Add route for url generated by the helper in app/config/routing.yml

imageResizer:
    resource: @ImageResizerBundle/Resources/config/routing.yml

Usage

just use the configured route in your image src attribute :

the following call will fetch the image from google website, store it in the configured cache manager, resize it using the format “small” defined in your configuration

<img src="/image/resize/small/homothetic?resource=http://www.google.fr/intl/fr_ALL/images/logos/images_logo_lg.gif">

the following call will fetch image from your local filesystem

<img src="/image/resize/small/homothetic?resource=foo/bar.gif" />

you can also use the helper

<img src="<?php echo $view['imageresizer']->url('foo/bar.gif', 'homothetic', 'small') ?>" />

or, if you are attentive to client side performance, use the image method that provides width and height attributes

<?php $view['imageresizer']->image('foo/bar.gif', 'homothetic', 'small', array('class' => 'test')) ?> // output <img src="/image/resize/small/homothetic?resource=foo/bar.gif" class="test" height="64" width="32"/>