mirror of
https://github.com/WordPress/WordPress.git
synced 2025-02-22 23:41:38 +01:00
Move the logic from WP_Image_Editor::get_quality() to WP_Image_Editor::set_quality(), so that 'wp_editor_set_quality' and 'jpeg_quality' filters run when setting the default value.
props markoheijnen. fixes #29856. Built from https://develop.svn.wordpress.org/trunk@30788 git-svn-id: http://core.svn.wordpress.org/trunk@30778 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
fbb5c1f1f5
commit
b2185048c6
@ -213,6 +213,23 @@ abstract class WP_Image_Editor {
|
|||||||
*/
|
*/
|
||||||
public function get_quality() {
|
public function get_quality() {
|
||||||
if ( ! $this->quality ) {
|
if ( ! $this->quality ) {
|
||||||
|
$this->set_quality();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->quality;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets Image Compression quality on a 1-100% scale.
|
||||||
|
*
|
||||||
|
* @since 3.5.0
|
||||||
|
* @access public
|
||||||
|
*
|
||||||
|
* @param int $quality Compression Quality. Range: [1,100]
|
||||||
|
* @return boolean|WP_Error True if set successfully; WP_Error on failure.
|
||||||
|
*/
|
||||||
|
public function set_quality( $quality = null ) {
|
||||||
|
if ( null === $quality ) {
|
||||||
/**
|
/**
|
||||||
* Filter the default image compression quality setting.
|
* Filter the default image compression quality setting.
|
||||||
*
|
*
|
||||||
@ -238,28 +255,11 @@ abstract class WP_Image_Editor {
|
|||||||
$quality = apply_filters( 'jpeg_quality', $quality, 'image_resize' );
|
$quality = apply_filters( 'jpeg_quality', $quality, 'image_resize' );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! $this->set_quality( $quality ) ) {
|
if ( $quality < 0 || $quality > 100 ) {
|
||||||
$this->quality = $this->default_quality;
|
$quality = $this->default_quality;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->quality;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets Image Compression quality on a 1-100% scale.
|
|
||||||
*
|
|
||||||
* @since 3.5.0
|
|
||||||
* @access public
|
|
||||||
*
|
|
||||||
* @param int $quality Compression Quality. Range: [1,100]
|
|
||||||
* @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.
|
// Allow 0, but squash to 1 due to identical images in GD, and for backwards compatibility.
|
||||||
if ( 0 === $quality ) {
|
if ( 0 === $quality ) {
|
||||||
$quality = 1;
|
$quality = 1;
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '4.1-beta2-30787';
|
$wp_version = '4.1-beta2-30788';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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
Block a user