Changeset 58692
- Timestamp:
- 07/09/2024 01:05:25 PM (3 months ago)
- Location:
- branches/6.6
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/6.6
-
branches/6.6/src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php
r58457 r58692 627 627 $height = (int) round( ( $size['height'] * $args['height'] ) / 100.0 ); 628 628 629 if ( $size['width'] !== $width &&$size['height'] !== $height ) {629 if ( $size['width'] !== $width || $size['height'] !== $height ) { 630 630 $result = $image_editor->crop( $crop_x, $crop_y, $width, $height ); 631 631 -
branches/6.6/tests/phpunit/tests/rest-api/rest-attachments-controller.php
r58457 r58692 2383 2383 2384 2384 /** 2385 * @ticket 61514 2386 * @requires function imagejpeg 2387 */ 2388 public function test_edit_image_crop_one_axis() { 2389 wp_set_current_user( self::$superadmin_id ); 2390 $attachment = self::factory()->attachment->create_upload_object( self::$test_file ); 2391 2392 $this->setup_mock_editor(); 2393 WP_Image_Editor_Mock::$size_return = array( 2394 'width' => 640, 2395 'height' => 480, 2396 ); 2397 2398 WP_Image_Editor_Mock::$edit_return['crop'] = new WP_Error(); 2399 2400 $request = new WP_REST_Request( 'POST', "/wp/v2/media/{$attachment}/edit" ); 2401 $request->set_body_params( 2402 array( 2403 'x' => 50, 2404 'y' => 0, 2405 'width' => 10, 2406 'height' => 100, 2407 'src' => wp_get_attachment_image_url( $attachment, 'full' ), 2408 2409 ) 2410 ); 2411 $response = rest_do_request( $request ); 2412 $this->assertErrorResponse( 'rest_image_crop_failed', $response, 500 ); 2413 2414 $this->assertCount( 1, WP_Image_Editor_Mock::$spy['crop'] ); 2415 $this->assertSame( 2416 array( 320, 0, 64, 480 ), 2417 WP_Image_Editor_Mock::$spy['crop'][0] 2418 ); 2419 } 2420 2421 /** 2385 2422 * @ticket 44405 2386 2423 * @requires function imagejpeg
Note: See TracChangeset
for help on using the changeset viewer.