I have a content type with several file fields. I have a view listing nodes of that content type. Now I want to add an exposed filters for each file field to let users filter only those nodes which have a file attached to corresponding field (or not have, whatever they choose).

So, I see choice options like this:

  • Any
  • Has file attached
  • No file attached

Is there a module for this? Or my only way is to write a custom Views filter?

3 Answers 3


Answering to myself :]

Add a new filter for, say, field_file:fid, make it exposed and choose Is not empty operator.

It will not work :D It is a known Views issue. Luckily, comment #70 in that issue has a patch to fix this operator behavior, apply it and enjoy :)

  • Patch works, but you get a strict warning. :-P Better than nothing.
    – Dalin
    Commented Feb 10, 2014 at 20:54

I was able to work around it using Grouped filters.

I added Content File:fid filter and exposed it.

Then I selected Grouped filters option (instead of the Single filter).

In the table that appears where you can set your options, the first one is Any (default), in the second one I added

Label YES
Operator Is greater than 
Value 0

and I removed the third table row as I didn't need it.

This filter works! It shows the filter with 2 options: Any and YES. Any is default and shows all results. If I select YES it only shows results that have a file attached :)

I also added Content: file among Fields so it's easy to test the filter.


My approach for this was based on experimentation on previous answer by prkos

My case included a image field with images uploaded to my site. So the file-path output for the field was - http://example.com/sites/default/files/001.png

In the views exposed filter, I have used File: Path (grouped) after adding relationship for file.

Now for the grouped options

- Any -
Yes | Operator: Length is greater than | Value: 0
No  | Operator: is empty (Null)        | Value: NULL

This works for me. This gives me a filter for whether an image field is empty or not.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.