Changeset 50951
- Timestamp:
- 05/22/2021 12:58:46 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-image-editor.php
r50943 r50951 323 323 * the mapping array is empty, so the mime type matches the source image. 324 324 * 325 * @see src/wp-includes/class-wp-image-editor.php ->get_output_format()325 * @see WP_Image_Editor::get_output_format() 326 326 * 327 327 * @since 5.8.0 328 328 * 329 * @param array $ wp_image_editor_output_format {329 * @param array $output_format { 330 330 * An array of mime type mappings. Maps a source mime type to a new 331 * destination mime type. Empty by default.331 * destination mime type. Default empty array. 332 332 * 333 333 * @type array $mime_type The source mime type { 334 334 * @type string $mime_type The new mime type. 335 335 * } 336 * @param string $filename Path to the image.336 * @param string $filename Path to the image. 337 337 * @param string $mime_type The source image mime type. 338 338 * } 339 339 */ 340 $wp_image_editor_output_format = apply_filters( 'image_editor_output_format', array(), $filename, $mime_type ); 341 342 if ( 343 isset( $wp_image_editor_output_format[ $mime_type ] ) && 344 $this->supports_mime_type( $wp_image_editor_output_format[ $mime_type ] ) 340 $output_format = apply_filters( 'image_editor_output_format', array(), $filename, $mime_type ); 341 342 if ( isset( $output_format[ $mime_type ] ) 343 && $this->supports_mime_type( $output_format[ $mime_type ] ) 345 344 ) { 346 $mime_type = $ wp_image_editor_output_format[ $mime_type ];347 $new_ext = $this->get_extension( $mime_type );345 $mime_type = $output_format[ $mime_type ]; 346 $new_ext = $this->get_extension( $mime_type ); 348 347 } 349 348 -
trunk/tests/phpunit/tests/image/intermediateSize.php
r50943 r50951 53 53 $image = image_make_intermediate_size( DIR_TESTDATA . '/images/a2-small.jpg', 100, 75, true ); 54 54 55 unlink( DIR_TESTDATA . '/images/a2-small-100x75.jpg' ); 56 55 57 $this->assertInternalType( 'array', $image ); 56 58 $this->assertSame( 100, $image['width'] ); … … 59 61 60 62 $this->assertFalse( isset( $image['path'] ) ); 61 62 unlink( DIR_TESTDATA . '/images/a2-small-100x75.jpg' ); 63 } 64 65 /** 66 * @requires function imagejpeg 63 } 64 65 /** 67 66 * @ticket 52867 67 * @requires function imagejpeg 68 68 */ 69 69 function test_image_editor_output_format_filter() { … … 74 74 } 75 75 ); 76 76 77 $file = DIR_TESTDATA . '/images/waffles.jpg'; 77 78 $image = image_make_intermediate_size( $file, 100, 75, true ); 78 79 $editor = wp_get_image_editor( $file ); 80 81 unlink( DIR_TESTDATA . '/images/' . $image['file'] ); 82 remove_all_filters( 'image_editor_output_format' ); 83 79 84 if ( is_wp_error( $editor ) || ! $editor->supports_mime_type( 'image/webp' ) ) { 80 85 $this->assertSame( 'image/jpeg', $image['mime-type'] ); … … 82 87 $this->assertSame( 'image/webp', $image['mime-type'] ); 83 88 } 84 unlink( DIR_TESTDATA . '/images/' . $image['file'] );85 remove_all_filters( 'image_editor_output_format' );86 89 } 87 90
Note: See TracChangeset
for help on using the changeset viewer.