Fix setting default quality in WP_Image_Editor.

props markoheijnen.
fixes #29856 for trunk.
Built from https://develop.svn.wordpress.org/trunk@29834


git-svn-id: http://core.svn.wordpress.org/trunk@29598 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2014-10-04 13:12:15 +00:00
parent b98f03669c
commit 221db8fd8d
4 changed files with 14 additions and 9 deletions

View File

@ -114,7 +114,7 @@ class WP_Image_Editor_GD extends WP_Image_Editor {
$this->update_size( $size[0], $size[1] );
$this->mime_type = $size['mime'];
return true;
return $this->set_quality();
}
/**

View File

@ -140,10 +140,11 @@ class WP_Image_Editor_Imagick extends WP_Image_Editor {
}
$updated_size = $this->update_size();
if ( is_wp_error( $updated_size ) )
return $updated_size;
if ( is_wp_error( $updated_size ) ) {
return $updated_size;
}
return true;
return $this->set_quality();
}
/**

View File

@ -236,10 +236,10 @@ abstract class WP_Image_Editor {
* @param string $context Context of the filter.
*/
$quality = apply_filters( 'jpeg_quality', $quality, 'image_resize' );
}
if ( ! $this->set_quality( $quality ) ) {
$this->quality = $this->default_quality;
}
if ( ! $this->set_quality( $quality ) ) {
$this->quality = $this->default_quality;
}
}
@ -256,8 +256,12 @@ abstract class WP_Image_Editor {
* @return boolean|WP_Error True if set successfully; WP_Error on failure.
*/
public function set_quality( $quality = null ) {
if ( null === $quality ) {
$quality = $this->default_quality;
}
// Allow 0, but squash to 1 due to identical images in GD, and for backwards compatibility.
if ( $quality == 0 ) {
if ( 0 === $quality ) {
$quality = 1;
}

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.1-alpha-20141003';
$wp_version = '4.1-alpha-20141004';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.