eZ Community » Forums » eZ Publish 5 Platform » ez_is_field_empty not working fine...

ez_is_field_empty not working fine with image fieldtype

ez_is_field_empty not working fine with image fieldtype

Tuesday 26 August 2014 10:01:29 am - 2 replies


ez_is_field_empty is not working on the image fieldtype.

the problem: one of my images got out of sync with my server. so, i didn't really has the image on my var folder, but the image was present on the DB. now, i get this big twig_error_runtime:

Impossible to access an attribute ( "uri" ) on a NULL variable ( "" ) in EzPublishCoreBundle::content_fields.html.twig at line 416

lets see what's behind. i render the field with ez_render_field:

 {{ ez_render_field(content, 'image', {'parameters': { 'alias': 'link' }}) }}

and the only why to test if the image is really there, is with the following statement:

{% if ez_field_value( content, 'image' ).uri is not null %}
{{ ez_render_field(....

 is there a better why to do this?


 thanks, Juan Pablo

Modified on Tuesday 26 August 2014 10:03:08 am by Juan Pablo Stumpf

Tuesday 26 August 2014 10:48:20 am

Hi Juan Pablo

I would say this is a bug. Can you please report it? Also it should be very easy to fix with a simple pull-request.

In content_fields.html.twig, line 416, just add an if block.

{% if imageAlias %}<img src="{{ asset( imageAlias.uri ) }}" width="{{ imageAlias.width }}" height="{{ imageAlias.height }}" alt="{{ field.value.alternativeText }}" />{% endif %}

Tuesday 26 August 2014 1:56:49 pm


okey, i did a pull-request -> https://github.com/ezsystems/ezpublish-kernel/pull/965


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

36 542 Users on board!

Forums menu

Proudly Developed with from