WordPress.org

Make WordPress Core

Opened 2 months ago

Last modified 7 weeks 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.0 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 2 months ago.
Grid view attachments filters drop-down
media-list-attachment-filter-dropdown.png (141.6 KB) - added by itzmekhokan 2 months ago.
List view attachment filters drop-down
43658.patch (1.3 KB) - added by itzmekhokan 2 months ago.
43658.1.patch (1.3 KB) - added by itzmekhokan 7 weeks ago.
Corrected coding standards by added whitespace

Download all attachments as: .zip

Change History (8)

@itzmekhokan
2 months ago

Grid view attachments filters drop-down

@itzmekhokan
2 months ago

List view attachment filters drop-down

@itzmekhokan
2 months ago

#1 @itzmekhokan
2 months ago

  • Keywords has-patch added

#2 @itzmekhokan
2 months ago

  • Keywords has-screenshots added

#3 @adamsilverstein
8 weeks 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
7 weeks ago

Corrected coding standards by added whitespace

#4 @itzmekhokan
7 weeks 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.

Note: See TracTickets for help on using tickets.