This site has been archived and you can no longer log in or post new messages. For up-to-date community resources please visit

eZ Community » Forums » Developer » ez_render_field & assetic

ez_render_field & assetic

ez_render_field & assetic

Monday 09 February 2015 9:39:43 am - 1 reply


I'm using the ezpublish version 2014.07 with the symfony2 frontend stack and I have a little problem with assetic when I’m loading a dynamic content.


Assetic configuration(config.yml):

                engines: ['twig', 'eztpl']
                assets_version: 'v10'


When I display a static image:

<img src="{{ asset('bundles/myBundle/images/image.jpg') }}" alt="">

 The url generated is: 'bundles/myBundle/images/image.jpg?v10'


OK but when I display an image in twig with the ez_render_field function:


{{ ez_render_field(content, 'image', {"parameters": {"alias": 'myAlias’} }) }}

The url generated is : /var/mysite/storage/images/myimage?v10


I’m using varnish and I’m losing the benefits ot it with this code generated


How can I disabled assetic when using ez_render_field function ?



Modified on Monday 09 February 2015 9:42:46 am by Tapia André

Tuesday 10 February 2015 4:02:52 pm

I solved my problem using:

 {{ ez_render_field(content, 'image', {"template": "myBundle:Fields:content_fields.html.twig", "parameters": {"alias": 'myAlias’} }) }}


With this temple conten_fields.html.twig:

 {% block ezimage_field %}
{% spaceless %}
{% if not ez_is_field_empty( content, field ) %}
<figure {{ block( 'field_attributes' ) }}>
    {% set imageAlias = ez_image_alias( field, versionInfo, parameters.alias|default( 'original' ) ) %}
    <img src="{{ imageAlias.uri }}" width="{{ imageAlias.width }}" height="{{ imageAlias.height }}" alt="{{ field.value.alternativeText }}" />
{% endif %}
{% endspaceless %}
{% endblock %}

=> without the asset() one the src param


I hope this will be usefull for someone


You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from