mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 14:20:15 +00:00
Media: Introduces image_editor_output_format filter for setting default MIME type of sub size image output.
This change introduces the `image_editor_output_format` filter, which fires as sub size images are generated allowing to define a default image MIME type for those items. Props adamsilverstein, williampatton, spacedmonkey, mikeschroder, hellofromTonya, justinahinon, Boniu91, antpb, SergeyBiryukov. Fixes #52867. git-svn-id: https://develop.svn.wordpress.org/trunk@50943 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -62,6 +62,29 @@ class Tests_Image_Intermediate_Size extends WP_UnitTestCase {
|
||||
unlink( DIR_TESTDATA . '/images/a2-small-100x75.jpg' );
|
||||
}
|
||||
|
||||
/**
|
||||
* @requires function imagejpeg
|
||||
* @ticket 52867
|
||||
*/
|
||||
function test_image_editor_output_format_filter() {
|
||||
add_filter(
|
||||
'image_editor_output_format',
|
||||
function() {
|
||||
return array( 'image/jpeg' => 'image/webp' );
|
||||
}
|
||||
);
|
||||
$file = DIR_TESTDATA . '/images/waffles.jpg';
|
||||
$image = image_make_intermediate_size( $file, 100, 75, true );
|
||||
$editor = wp_get_image_editor( $file );
|
||||
if ( is_wp_error( $editor ) || ! $editor->supports_mime_type( 'image/webp' ) ) {
|
||||
$this->assertSame( 'image/jpeg', $image['mime-type'] );
|
||||
} else {
|
||||
$this->assertSame( 'image/webp', $image['mime-type'] );
|
||||
}
|
||||
unlink( DIR_TESTDATA . '/images/' . $image['file'] );
|
||||
remove_all_filters( 'image_editor_output_format' );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 17626
|
||||
* @requires function imagejpeg
|
||||
|
||||
Reference in New Issue
Block a user