Ticket #29856: 29856.diff
File 29856.diff, 5.0 KB (added by , 10 years ago) |
---|
-
src/wp-includes/class-wp-image-editor-gd.php
114 114 $this->update_size( $size[0], $size[1] ); 115 115 $this->mime_type = $size['mime']; 116 116 117 return true;117 return $this->set_quality(); 118 118 } 119 119 120 120 /** -
src/wp-includes/class-wp-image-editor-imagick.php
140 140 } 141 141 142 142 $updated_size = $this->update_size(); 143 if ( is_wp_error( $updated_size ) ) 144 return $updated_size; 143 if ( is_wp_error( $updated_size ) ) { 144 return $updated_size; 145 } 145 146 146 return true;147 return $this->set_quality(); 147 148 } 148 149 149 150 /** -
src/wp-includes/class-wp-image-editor.php
236 236 * @param string $context Context of the filter. 237 237 */ 238 238 $quality = apply_filters( 'jpeg_quality', $quality, 'image_resize' ); 239 } 239 240 240 if ( ! $this->set_quality( $quality ) ) { 241 $this->quality = $this->default_quality; 242 } 241 if ( ! $this->set_quality( $quality ) ) { 242 $this->quality = $this->default_quality; 243 243 } 244 244 } 245 245 … … 256 256 * @return boolean|WP_Error True if set successfully; WP_Error on failure. 257 257 */ 258 258 public function set_quality( $quality = null ) { 259 if ( $quality == null ) { 260 $quality = $this->default_quality; 261 } 262 259 263 // Allow 0, but squash to 1 due to identical images in GD, and for backwards compatibility. 260 if ( $quality == 0 ) {264 if ( $quality === 0 ) { 261 265 $quality = 1; 262 266 } 263 267 -
tests/phpunit/tests/image/editor.php
52 52 // Get an editor 53 53 $editor = wp_get_image_editor( DIR_TESTDATA . '/images/canola.jpg' ); 54 54 55 // Check default value 56 $this->assertEquals( 90, $editor->get_quality() ); 57 55 58 // Ensure set_quality works 56 59 $this->assertTrue( $editor->set_quality( 75 ) ); 57 60 $this->assertEquals( 75, $editor->get_quality() ); … … 59 62 // Ensure the quality filter works 60 63 $func = create_function( '', "return 100;"); 61 64 add_filter( 'wp_editor_set_quality', $func ); 62 $this->assertTrue( $editor->set_quality( 7 5) );63 $this->assertEquals( 7 5, $editor->get_quality() );65 $this->assertTrue( $editor->set_quality( 70 ) ); 66 $this->assertEquals( 70, $editor->get_quality() ); 64 67 65 68 // Clean up 66 69 remove_filter( 'wp_editor_set_quality', $func ); -
tests/phpunit/tests/image/editor_gd.php
463 463 $file = DIR_TESTDATA . '/images/transparent.png'; 464 464 465 465 $editor = wp_get_image_editor( $file ); 466 467 $this->assertNotInstanceOf( 'WP_Error', $editor ); 468 466 469 $editor->load(); 467 470 $editor->resize( 5, 5 ); 468 471 $save_to_file = tempnam( get_temp_dir(), '' ) . '.png'; … … 483 486 $file = DIR_TESTDATA . '/images/transparent.png'; 484 487 485 488 $editor = wp_get_image_editor( $file ); 489 490 $this->assertNotInstanceOf( 'WP_Error', $editor ); 491 486 492 $editor->load(); 487 493 488 494 $save_to_file = tempnam( get_temp_dir(), '' ) . '.png'; -
tests/phpunit/tests/image/editor_imagick.php
463 463 $file = DIR_TESTDATA . '/images/transparent.png'; 464 464 465 465 $editor = wp_get_image_editor( $file ); 466 467 $this->assertNotInstanceOf( 'WP_Error', $editor ); 468 466 469 $editor->load(); 467 470 $editor->resize( 5, 5 ); 468 471 $save_to_file = tempnam( get_temp_dir(), '' ) . '.png'; … … 483 486 $file = DIR_TESTDATA . '/images/transparent.png'; 484 487 485 488 $editor = wp_get_image_editor( $file ); 489 490 $this->assertNotInstanceOf( 'WP_Error', $editor ); 491 486 492 $editor->load(); 487 493 488 494 $save_to_file = tempnam( get_temp_dir(), '' ) . '.png'; -
tests/phpunit/tests/image/functions.php
224 224 225 225 // Save the image as each file extension, check the mime type 226 226 $img = wp_get_image_editor( DIR_TESTDATA . '/images/canola.jpg' ); 227 $this->assertNotInstanceOf( 'WP_Error', $img ); 228 227 229 $temp = get_temp_dir(); 228 230 foreach ( $mime_types as $ext => $mime_type ) { 229 231 $file = wp_unique_filename( $temp, uniqid() . ".$ext" );