It would be great to have a views filter allow you to filter out nodes where there is no image uploaded for that field.

Comments

dorien’s picture

Same feature request.

I need this so I can put a custom empty text for users who don't have any images uploaded. I am sure this worked before in 5.x

Thanks for the great module by the way. My favorite way of handling images!

mandclu’s picture

+1 for adding a views filter

dorien’s picture

Or can we do this with a view of the type "file". I'll try that!

************
Update: nope, sorry, that doesn't seem to work :-)

dorien’s picture

Version: 6.x-3.x-dev » 6.x-3.0-alpha2

Here is a temporary way around the issue:
Instead of adding an empty text, I added a footer with the following code:

<?php 
$node=node_load(arg(1));
if(!$node->field_avatar[0]['status']){
echo "empty text goes here";
}
?>

This does require you to have the nid argument in the url, otherwise it won't work. You also need to replace field_avatar by whichever you imagefield is called.

Greetings!

Dorien
***********

Update: just as an example, I use this to display a default avatar I made when there is no avatar:

<?php 
$node=node_load(arg(1));
if(!$node->field_avatar[0]['status']){
echo '<img src="'.base_path().'sites/default/files/avatars/defaultavatar.png" />';
}
?>
tech4him’s picture

+1 more for adding this filter. Would be a great addition.

drewish’s picture

Category: feature » support
Status: Active » Closed (duplicate)

see #317784: filter by imagefield with views 6.x? for instructions on how to setup a relationship.

dorien’s picture

Worked for me! Thanks.