Problem/Motivation

I know there were issues previously reported that are related to this, but I'm still experiencing an issue where contextual filters aren't being respected for media type in the media library widget modal with "Show all files in Root directory" setting checked on. This is specific to fields that reference media and use Media Library widget in form display. When adding media to a node through that field, the modal pops up, you can see the tabs showing each available media type, but all existing media displays no matter which tab is selected. I would expect the media to be filtered depending on the selected tab.

Steps to reproduce

  • Enable Media
  • Enable Media Library
  • Require latest, stable Media Directories via composer (2.0.1) with jsTree library
  • Enable Media Directories + dependent modules
  • Add new field to content type (basic page or article) that references Media (chose Image, Remote Video, Document)
  • Make sure Media Library widget is selected for the field's form display
  • Check "Show all files in Root directory" at Media directories settings: /admin/config/media/media_directories
  • Upload a few new media items: image, video, and file
  • Create or edit content type with new Media reference field, Add media to get the modal with the tabs.
  • Notice all media types display no matter what tab is selected, there's no contextual filtering.
  • Unchecking "Show all files in Root directory" at Media directories settings: /admin/config/media/media_directories will respect the contextual filters

Proposed resolution

  • Possibly update the group id in the query in the MediaDirectory view filter? Similar to solution from related issue with MediaDirectoryArgument
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

brittany.huntzberry created an issue. See original summary.

ytsurk’s picture

Assigned: Unassigned » ytsurk
Priority: Normal » Critical

Thank you for reporting this issue, with a super clear summary. I'll have a deeper look soonish.

This means, we're breaking the media libraries Add-Form, which shall be considered as critical bug.

ytsurk’s picture

Assigned: ytsurk » Unassigned
Status: Active » Needs review
FileSize
1.05 KB

We need to create a new query group instead of re-using the existing group 0.

ytsurk’s picture

FileSize
4.58 KB

Expanded to all "queries" and adjusted the jsTree Root label, if "show all files in root directory" is set.

brittany.huntzberry’s picture

Assigned: Unassigned » brittany.huntzberry
Status: Needs review » Reviewed & tested by the community

Thank you so much for creating a patch so quickly! I've applied patch #4 locally without any issues.

I checked the media library widget modal and the contextual filter is now respected with the setting checked on. I also did a check without the setting on and it also works as designed. I didn't notice any major regressions either, thanks again!

  • ytsurk committed e111810 on 2.x
    Issue #3186374 by ytsurk, brittany.huntzberry: Media type contextual...
ytsurk’s picture

Assigned: brittany.huntzberry » Unassigned
Status: Reviewed & tested by the community » Fixed

Thank you for reviewing :D

Status: Fixed » Closed (fixed)

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