From 221db8fd8dde948e11d7cbb3f2b890505ec14c3f Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sat, 4 Oct 2014 13:12:15 +0000 Subject: [PATCH] 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 --- wp-includes/class-wp-image-editor-gd.php | 2 +- wp-includes/class-wp-image-editor-imagick.php | 7 ++++--- wp-includes/class-wp-image-editor.php | 12 ++++++++---- wp-includes/version.php | 2 +- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/wp-includes/class-wp-image-editor-gd.php b/wp-includes/class-wp-image-editor-gd.php index ef804571c6..ae65813eff 100644 --- a/wp-includes/class-wp-image-editor-gd.php +++ b/wp-includes/class-wp-image-editor-gd.php @@ -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(); } /** diff --git a/wp-includes/class-wp-image-editor-imagick.php b/wp-includes/class-wp-image-editor-imagick.php index 8bd6e38861..fd9d6541f1 100644 --- a/wp-includes/class-wp-image-editor-imagick.php +++ b/wp-includes/class-wp-image-editor-imagick.php @@ -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(); } /** diff --git a/wp-includes/class-wp-image-editor.php b/wp-includes/class-wp-image-editor.php index 5792df3162..a4f2e3991b 100644 --- a/wp-includes/class-wp-image-editor.php +++ b/wp-includes/class-wp-image-editor.php @@ -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; } diff --git a/wp-includes/version.php b/wp-includes/version.php index 45970aa995..5e49ea773e 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -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.