Media: grid view attachment filter drop down - only show available mime types.

In the media library gird view, properly limit the media attachment filter to available mime types, matching the list view.

Props itzmekhokan.
Fixes #43658.


git-svn-id: https://develop.svn.wordpress.org/trunk@44947 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Adam Silverstein
2019-03-20 20:06:22 +00:00
parent 0a875f0170
commit 7d0d69af4a
2 changed files with 56 additions and 1 deletions

View File

@@ -3576,10 +3576,18 @@ function wp_enqueue_media( $args = array() ) {
$month_year->text = sprintf( __( '%1$s %2$d' ), $wp_locale->get_month( $month_year->month ), $month_year->year );
}
// Filter to show only available mime types.
$avail_post_mime_types = get_available_post_mime_types( 'attachment' );
$mimeTypes = wp_list_pluck( get_post_mime_types(), 0 );
foreach ( $mimeTypes as $mime_type => $label ) {
if ( ! wp_match_mime_types( $mime_type, $avail_post_mime_types ) ) {
unset( $mimeTypes[ $mime_type ] );
}
}
$settings = array(
'tabs' => $tabs,
'tabUrl' => add_query_arg( array( 'chromeless' => true ), admin_url( 'media-upload.php' ) ),
'mimeTypes' => wp_list_pluck( get_post_mime_types(), 0 ),
'mimeTypes' => $mimeTypes,
/** This filter is documented in wp-admin/includes/media.php */
'captions' => ! apply_filters( 'disable_captions', '' ),
'nonce' => array(