media_taxonomy_filter
This lightweight module is trying to solve the problem that Views filter named "Content has taxonomy term ID (with depth)" is available only for nodes and can not be used for media entities.
Related issue in Drupal Core : Views should support - Entity: Has taxonomy term ID (with depth) - for entities
The Module extends Taxonomy module from Drupal core and provides a new filter "Media has taxonomy term ID (with depth)".
Compared to the Taxonomy module that uses relationship table "taxonomy_index" between terms and nodes, this module uses only SQL query on existing tables. Module needs to know the name of your reference field. You must specify the field in the filter settings.
How to use
- Go to your Media Views -> Advanced -> Contextual filters -> Add -> Media has taxonomy term ID (with depth)
- In Reference field: Enter a machine name of the field in the media entity type, which is referencing to a taxonomy
Most of this module code comes from Commerce: Product taxonomy filter. A big thanks to this project maintainers.
8.x-1.x vs 8.x-2.x
Drupal core 8.6 introduces modifications in taxonomy table in database.
Use 8.x-2.x version of this module if your drupal core version is >= 8.6