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:
parent
b98f03669c
commit
221db8fd8d
|
@ -114,7 +114,7 @@ class WP_Image_Editor_GD extends WP_Image_Editor {
|
||||||
$this->update_size( $size[0], $size[1] );
|
$this->update_size( $size[0], $size[1] );
|
||||||
$this->mime_type = $size['mime'];
|
$this->mime_type = $size['mime'];
|
||||||
|
|
||||||
return true;
|
return $this->set_quality();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -140,10 +140,11 @@ class WP_Image_Editor_Imagick extends WP_Image_Editor {
|
||||||
}
|
}
|
||||||
|
|
||||||
$updated_size = $this->update_size();
|
$updated_size = $this->update_size();
|
||||||
if ( is_wp_error( $updated_size ) )
|
if ( is_wp_error( $updated_size ) ) {
|
||||||
return $updated_size;
|
return $updated_size;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return $this->set_quality();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -236,10 +236,10 @@ abstract class WP_Image_Editor {
|
||||||
* @param string $context Context of the filter.
|
* @param string $context Context of the filter.
|
||||||
*/
|
*/
|
||||||
$quality = apply_filters( 'jpeg_quality', $quality, 'image_resize' );
|
$quality = apply_filters( 'jpeg_quality', $quality, 'image_resize' );
|
||||||
|
}
|
||||||
|
|
||||||
if ( ! $this->set_quality( $quality ) ) {
|
if ( ! $this->set_quality( $quality ) ) {
|
||||||
$this->quality = $this->default_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.
|
* @return boolean|WP_Error True if set successfully; WP_Error on failure.
|
||||||
*/
|
*/
|
||||||
public function set_quality( $quality = null ) {
|
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.
|
// Allow 0, but squash to 1 due to identical images in GD, and for backwards compatibility.
|
||||||
if ( $quality == 0 ) {
|
if ( 0 === $quality ) {
|
||||||
$quality = 1;
|
$quality = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @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.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue