0

I have a content type that has a media field that can contain audio, video or image, I created a view and I want to filter the view depending on the media type is that possible using Drupal views or do I need to make custom code for this

4
  • More details please. There's type property for Media already.
    – Nikit
    Commented May 10, 2021 at 1:43
  • Yes I know, but when I choose filter option on the image field, I am not getting the types there Commented May 10, 2021 at 1:57
  • Image field isn't Media. It's belong to Media entity type. So you need to add relationship that connect Media with Image field.
    – Nikit
    Commented May 10, 2021 at 2:41
  • @Nikit thanks I did it like this, sorry for this stupid question I am just new to drupal Commented May 10, 2021 at 4:28

1 Answer 1

0

You can add more info about the referenced Media in your content Views through a Relationship for that Media field.

Add the Relationship (under Advanced Views settings) called something like Media referenced from field_mixed_media under the Content Category.

You can Require it if you only want to see nodes that have that Field filled in (not empty).

Once you add that Relationship you will see more options when adding new Fields and Filters.

In your case you'll want to add the Filter Media type from the Media Category, it will use the Relationship by default, and Expose it.

The Exposed filter will show as a drop-down select list. If you want it display as checkboxes you can use the Better Exposed Filters module.

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.