WordPress.org

Make WordPress Core

Changeset 30788


Ignore:
Timestamp:
12/08/2014 04:18:42 PM (5 years ago)
Author:
SergeyBiryukov
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-image-editor.php

    r29834 r30788  
    214214    public function get_quality() {
    215215        if ( ! $this->quality ) {
     216            $this->set_quality();
     217        }
     218
     219        return $this->quality;
     220    }
     221
     222    /**
     223     * Sets Image Compression quality on a 1-100% scale.
     224     *
     225     * @since 3.5.0
     226     * @access public
     227     *
     228     * @param int $quality Compression Quality. Range: [1,100]
     229     * @return boolean|WP_Error True if set successfully; WP_Error on failure.
     230     */
     231    public function set_quality( $quality = null ) {
     232        if ( null === $quality ) {
    216233            /**
    217234             * Filter the default image compression quality setting.
     
    239256            }
    240257
    241             if ( ! $this->set_quality( $quality ) ) {
    242                 $this->quality = $this->default_quality;
     258            if ( $quality < 0 || $quality > 100 ) {
     259                $quality = $this->default_quality;
    243260            }
    244         }
    245 
    246         return $this->quality;
    247     }
    248 
    249     /**
    250      * Sets Image Compression quality on a 1-100% scale.
    251      *
    252      * @since 3.5.0
    253      * @access public
    254      *
    255      * @param int $quality Compression Quality. Range: [1,100]
    256      * @return boolean|WP_Error True if set successfully; WP_Error on failure.
    257      */
    258     public function set_quality( $quality = null ) {
    259         if ( null === $quality ) {
    260             $quality = $this->default_quality;
    261261        }
    262262
Note: See TracChangeset for help on using the changeset viewer.