You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
5 years ago | |
---|---|---|
Cache | 10 years ago | |
Controller | 5 years ago | |
DependencyInjection | 10 years ago | |
Extensions | 5 years ago | |
Image | 5 years ago | |
Resources/config | 5 years ago | |
Templating/Helper | 5 years ago | |
Tests/Templating/Helper | 12 years ago | |
ImageResizerBundle.php | 12 years ago | |
README.markdown | 10 years ago | |
composer.json | 5 years 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"/>