I want the content to display in views if the content contains an image, otherwise hide it.

I searched in the filter and I couldn't find such option, does anyone have the solution?

Comments

xiaomo created an issue. See original summary.

millionleaves’s picture

When you say "if the content contains an image", do you mean that you have an image field and you only want the content to display in the view if there is an image loaded into the image field?

Subhransu.addweb’s picture

Please follow the below steps for your solution:

1.Take all field you want to display and set "Exclude from display".
2.Take image field on setting "Rewrite results" section, check checkbox "Rewrite the output of this field "and display all field using "Replacement patterns".
3.In image field setting "Show No results behavior" check checkbox "Hide if empty".

Hope this information help you.

Thanks!

dishabhadra’s picture

Assigned: Unassigned » dishabhadra
dishabhadra’s picture

If in content type you having Image field and you are saying if data present in image field then show that content in view othewise hide then follow the below steps :

1. Create view. Add filter of content type.
2. Add all the fields which you want to display.
3. Add one more filter of that Image field and in operator select is not empty(NOT NULL).
4. Now view will show result of content which contains an image.

Thanks!

dishabhadra’s picture

Assigned: dishabhadra » Unassigned
renatog’s picture

Status: Active » Reviewed & tested by the community

Hi @xiaomo, how are you?

I checked and @denisha.addweb and @dishabhadra are correct.

Thank you very much for your contributions.

Good Work.

Best,

renatog’s picture

Status: Reviewed & tested by the community » Fixed

@xiaomo, please follow this steps and any question feels free to comment again, all right?

Best,

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.