Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Symfony 2.7 : asset component not working with imagine_filter

With the introduction of the asset component in Symfony 2.7, how can I output the relative url of an asset without a version number ?

I am using the following code whcih does not work anymore :

<img src="{{ asset('images/user.png') | imagine_filter('default') }}" alt="Image de profil" class="img-circle whitebg">

The asset function outputs an url with a version number and this is not handled properly by the imagine_filter :

http://mywebsite.com/media/cache/resolve/default/images/user.png%3Fversion=v1.0

My config :

framework:
    assets:
        version: 'v1.0'
        version_format: '%%s?version=%%s'
        base_path: ~
        packages:
            images:
                base_path: /images
                version_format: ''

Ideally I would be able to make the imagine filter work while keeping this versionning strategy Otherwise, deactivating the versioning for images could be good enough

Thanks for your help !

like image 390
Sébastien Avatar asked Oct 18 '15 16:10

Sébastien


1 Answers

Apply the filter to the relative path directly, asset() can be seen as a sort of helper:

<img src="{{ asset('user.png'|imagine_filter('default')) }}">

You can also sett the version (4th parameter) to false:

<img src="{{ asset('user.png'|imagine_filter('default'), null, false, false) }}">
like image 63
Rvanlaak Avatar answered Nov 07 '22 07:11

Rvanlaak