Integration of the imgix library into Symfony., (*1)
Installation
The best way to install this bundle is by using Composer., (*2)
For Symfony 2.x run:, (*3)
``` bash
$ php composer.phar require tacticmedia/imgix-bundle ~1.0, (*4)
For Symfony 3.4+ run:
``` bash
$ php composer.phar require tacticmedia/imgix-bundle ~2.0
For Symfony 4+ run:, (*5)
``` bash
$ php composer.phar require tacticmedia/imgix-bundle ~3.0, (*6)
For Symfony 4+ with PHP 7.1 run:
``` bash
$ php composer.phar require tacticmedia/imgix-bundle ^4.0
Then, enable the bundle:, (*7)
``` php
<?php
// app/AppKernel.php, (*8)
public function registerBundles()
{
$bundles = array(
// ...
new Tacticmedia\ImgixBundle\TacticmediaImgixBundle(),
);
}, (*9)
Finally add your sources:
```yml
tacticmedia_imgix:
enabled: true
default_source: 'folder'
sources:
folder:
domain: 'acme.imgix.net'
proxy:
domain: 'acme-proxy.imgix.net'
sign_key: 'abcd1234'
Usage
In your Twig template just do:, (*10)
<img src="{{ imgix('https://assets-cdn.github.com/images/modules/logos_page/Octocat.png', source='proxy', width=200, height=166) }}" width="200" height="166"/>
<img src="{{ imgix('images/modules/logos_page/Octocat.png', w=200, h=166) }}" width="200" />
You should put the enabled
and domains[]
setting in your parameters to be able to enable imgix for different environments., (*11)
License
This bundle is released under the MIT license. See the complete license in the
bundle:, (*12)
Resources/meta/LICENSE
Credits
This repository is based on https://github.com/GoldenLine/ImgixBundle which seems to be abandoned and not up-to-date with
Symfony progress., (*13)