No content but empty row outputted by view I have a view as follows:


Display: Master
Format: Unformatted list
Fields: Content: Images
Filter criteria: Content type, published
Contextual filter: Content: Nid with 'Provide default value' set to 'Content ID from URL'


The view is placed on the node using Panels and Panalizer modules.

The node in question had no images uploaded to the image field but the view is outputting an empty row as follows:

&lt;div class="view view-case-study-images view-id-case_study_images view-display-id-default view-dom-id-0c286f7a769d643d2e0cf9709edc0c79"&gt;
  &lt;div class="view-content"&gt;
    &lt;div class="views-row views-row-1 views-row-odd views-row-first views-row-last"&gt; &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;


I have checked and unchecked the 'Count the number 0 as empty' and ' Hide if empty' on the 'Content: Images' field but the view still shows.

How can I hide the view (by removing this empty row) if there are no images on a node?

Happy to attach any additional information you require to this post. Thanks.
You need to set a filter value on the image field. 

Open your view, then edit as follows:

Enable 'Use Aggregation'.

Make sure that the image field is aggregating on 'Group Result together', using Group column 'Entity ID'. Sometimes views gives an error here, so just remove and re-add the image field with these settings.



Add a Filter criteria using 'field_image:fid', set its aggregation to COUNT, and choose the operator 'Is greater than' with value 0.

You might have to remove all of your sort criteria and re-add them as switching on aggregation mid stream can cause issues with sorting.

Basically, what you have done is to do a count on the image primary key (fid) for each node, and if the count is 0 to exclude the record from the result.

This should work for an image field that has either a single, or multiple values.

I you are uncomfortable working with aggregation, then have a look at the Field Count Formatter module. It adds a views field that simply count the number of values contained in a multi-value field. I would imagine it providing a filter in views as well.