WordPress.org

Make WordPress Core

Opened 23 months ago

Last modified 4 months ago

#43656 new defect (bug)

Media attachment filter does not work after switching list mode to grid for image attachment filter

Reported by: itzmekhokan Owned by:
Milestone: Awaiting Review Priority: normal
Severity: major Version: 4.9.4
Component: Media Keywords: has-screenshots needs-patch dev-feedback
Focuses: Cc:
PR Number:

Description

On media library if you switch to List mode and try to filter by image type attachment filter, it's perfectly filtered by image type in list mode.
Now at this time try to switch media mode to Grid, you will see all the attachments filtered by image type. And now if you try to filter by any attachments type filter in grid mode, it does not work. Only faced this issue for image type filter for switching mode List to Grid. Rest of attachments filters works perfectly in above case.

Attachments (3)

media-attachment-filter-doesnt-work.mp4 (2.0 MB) - added by itzmekhokan 23 months ago.
After filter by image type from media attachment filter and then after switching mode list to grid attachment filter doesn't work in grid filter
Bildschirmfoto 2019-10-24 um 10.29.22.png (138.6 KB) - added by zodiac1978 4 months ago.
Used filter "Documents" in list view (showing just Documents correctly)
Bildschirmfoto 2019-10-24 um 10.29.41.png (74.7 KB) - added by zodiac1978 4 months ago.
Switching to Grid view - the dropwdown shows "All media" but the output is still just "Documents" because of attachment-filter in URL

Change History (7)

@itzmekhokan
23 months ago

After filter by image type from media attachment filter and then after switching mode list to grid attachment filter doesn't work in grid filter

#1 @itzmekhokan
23 months ago

  • Keywords has-screenshots added

#2 @netsurfer2705
22 months ago

  • Severity changed from normal to major

I can confirm this bug!
It is caused by the presence of the "attachment-filter" in the URL, if it has any value other than empty.

The href attribute of the "view-switch" icon (id:'view-switch-grid') holds all the query parameters, which are then (falsely) used for the ajax query.
And if the first query for grid view does have a value for "attachment-filter", then you'll never be able to see "all" media!

BTW: The ajax query is also totally "buggy". Normally one should be able to change the $query parameter byy using the 'ajax_query_attachments_args' filter. But this will have no effect for most of the query parameters, because some of them are hardcoded elsewhere in core!!!

So there is no easy fix for this. Because to get it right, I would also expect the mime-type selection drop-down to be set to choosen value from the list view (and of course to work for "all").

Also one should think about the trash option (if enabled), where all other filters should be ignored.

@zodiac1978
4 months ago

Used filter "Documents" in list view (showing just Documents correctly)

@zodiac1978
4 months ago

Switching to Grid view - the dropwdown shows "All media" but the output is still just "Documents" because of attachment-filter in URL

#3 @zodiac1978
4 months ago

  • Keywords needs-patch dev-feedback added

This ticket was mentioned in Slack in #core-media by zodiac1978. View the logs.


4 months ago

Note: See TracTickets for help on using tickets.