WordPress.org

Make WordPress Core

Opened 10 months ago

Last modified 7 days ago

#43658 assigned defect (bug)

Media attachment filter drop-down mime types in grid mode is not properly filtered by available mime types

Reported by: itzmekhokan Owned by: adamsilverstein
Milestone: 5.2 Priority: normal
Severity: normal Version: 4.9.4
Component: Media Keywords: has-patch has-screenshots needs-testing needs-unit-tests
Focuses: Cc:

Description

In Gird mode media attachment filter is not properly filtered by available mime types, it shows all mime types by default via -

get_post_mime_types()

But in List mode its already filtered by checking

if ( ! wp_match_mime_types( $mime_type, $avail_post_mime_types ) ) {
	continue;
}

Attachments (4)

media-grid-attachment-filter-dropdown.png (330.0 KB) - added by itzmekhokan 10 months ago.
Grid view attachments filters drop-down
media-list-attachment-filter-dropdown.png (141.6 KB) - added by itzmekhokan 10 months ago.
List view attachment filters drop-down
43658.patch (1.3 KB) - added by itzmekhokan 10 months ago.
43658.1.patch (1.3 KB) - added by itzmekhokan 10 months ago.
Corrected coding standards by added whitespace

Download all attachments as: .zip

Change History (10)

@itzmekhokan
10 months ago

Grid view attachments filters drop-down

@itzmekhokan
10 months ago

List view attachment filters drop-down

@itzmekhokan
10 months ago

#1 @itzmekhokan
10 months ago

  • Keywords has-patch added

#2 @itzmekhokan
10 months ago

  • Keywords has-screenshots added

#3 @adamsilverstein
10 months ago

  • Keywords needs-testing needs-unit-tests added
  • Milestone changed from Awaiting Review to 5.0
  • Owner set to adamsilverstein
  • Status changed from new to assigned

@itzmekhokan thanks for the bug report and patch!

Overall your patch looks good and I see the issue you are trying to resolve. Can you please provide the code snippet you are using to alter the dropdown for testing? Also, it would be nice to add a a unit test confirming the filter works as expected and changes the return from wp_enqueue_media.

One small coding standards correction, this line is missing some whitespace before/after brackets: unset($mimeTypes[$mime_type]);

@itzmekhokan
10 months ago

Corrected coding standards by added whitespace

#4 @itzmekhokan
10 months ago

I have tested the flow thoroughly with the 43658.1.patch and it is working properly, as expected and changes the return from wp_enqueue_media.

However, I faced an issue with unit testing. Can you please guide me with the flow, i need to follow for the same.

Looking for your co-operation dearly.

#5 @pento
3 months ago

  • Milestone changed from 5.0 to 5.1

#6 @adamsilverstein
7 days ago

  • Milestone changed from 5.1 to 5.2

This one needs some more attention before its ready. Punting to 5.2.

Note: See TracTickets for help on using tickets.