Model field of view and hide if empty Hello this is my file views-view-field--sitemap--views-data-export--field-image.tpl.php :

&lt;?php

$fields["field_image"]-&gt;content = '&lt;image:loc&gt;' . $field-&gt;original_value . '&lt;/image:loc&gt;' . '&lt;image:title&gt;' . $row-&gt;field_field_image[0]['rendered']['#item']["alt"] . '&lt;/image:title&gt;';

echo $fields["field_image"]-&gt;content;


When I check the box to hide empty if the image field, the empty fields are hidden in the preview of view but not out. How to hide empty fields when the view is displayed? I think there is a line to add in the template file.
&lt;?php

if (!empty($field-&gt;original_value)) {

  $fields["field_image"]-&gt;content = '&lt;image:loc&gt;' . $field-&gt;original_value . '&lt;/image:loc&gt;' . '&lt;image:title&gt;' . $row-&gt;field_field_image[0]['rendered']['#item']["alt"] . '&lt;/image:title&gt;';

  echo $fields["field_image"]-&gt;content;

}