mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-04-02 11:44:33 +00:00
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:
@@ -465,6 +465,53 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
$this->assertNotEmpty( $mimes );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that the media grid uses the correct available single media type.
|
||||
* @ticket 43658
|
||||
*/
|
||||
function test_wp_enqueue_media_single_mime_type() {
|
||||
$filename = DIR_TESTDATA . '/images/test-image.jpg';
|
||||
$contents = file_get_contents( $filename );
|
||||
$upload = wp_upload_bits( basename( $filename ), null, $contents );
|
||||
$attachment_id = $this->_make_attachment( $upload );
|
||||
|
||||
add_filter(
|
||||
'media_view_settings',
|
||||
function( $settings ) {
|
||||
$this->assertEquals( array( 'image' ), array_keys( $settings['mimeTypes'] ) );
|
||||
return $settings;
|
||||
}
|
||||
);
|
||||
wp_enqueue_media();
|
||||
remove_all_filters( 'media_view_settings' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that the media grid uses the correct available multiple media types.
|
||||
* @ticket 43658
|
||||
*/
|
||||
function test_wp_enqueue_media_multiple_mime_types() {
|
||||
$filename = DIR_TESTDATA . '/images/test-image.jpg';
|
||||
$contents = file_get_contents( $filename );
|
||||
$upload = wp_upload_bits( basename( $filename ), null, $contents );
|
||||
$attachment_id = $this->_make_attachment( $upload );
|
||||
|
||||
$filename = DIR_TESTDATA . '/uploads/small-audio.mp3';
|
||||
$contents = file_get_contents( $filename );
|
||||
$upload = wp_upload_bits( basename( $filename ), null, $contents );
|
||||
$attachment_id = $this->_make_attachment( $upload );
|
||||
|
||||
add_filter(
|
||||
'media_view_settings',
|
||||
function( $settings ) {
|
||||
$this->assertEquals( array( 'image', 'audio' ), array_keys( $settings['mimeTypes'] ) );
|
||||
return $settings;
|
||||
}
|
||||
);
|
||||
wp_enqueue_media();
|
||||
remove_all_filters( 'media_view_settings' );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 21594
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user