Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment #2
millionleaves CreditAttribution: millionleaves as a volunteer and commentedWhen 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?
Comment #3
Subhransu.addweb CreditAttribution: Subhransu.addweb at AddWeb Solution Pvt. Ltd. commentedPlease 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!
Comment #4
dishabhadra CreditAttribution: dishabhadra at Blisstering Solutions commentedComment #5
dishabhadra CreditAttribution: dishabhadra at Blisstering Solutions commentedIf 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!
Comment #6
dishabhadra CreditAttribution: dishabhadra at Blisstering Solutions commentedComment #7
renatogHi @xiaomo, how are you?
I checked and @denisha.addweb and @dishabhadra are correct.
Thank you very much for your contributions.
Good Work.
Best,
Comment #8
renatog@xiaomo, please follow this steps and any question feels free to comment again, all right?
Best,