WordPress.org

Make WordPress Core


Ignore:
Timestamp:
11/16/2012 10:02:21 PM (7 years ago)
Author:
ryan
Message:

Add abstract methods back to WP_Image_Editor and refresh phpdoc.

Props DH-Shredder, markoheijnen, kurtpayne, nacin
see #6821

File:
1 edited

Legend:

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

    r22511 r22619  
    6363
    6464        if ( ! $required_methods )
    65             $required_methods = apply_filters( 'wp_image_editor_default_methods',
    66                 array( 'resize', 'multi_resize', 'crop', 'rotate', 'flip', 'stream' ) );
     65            $required_methods = array();
    6766
    6867        // Loop over each editor on each request looking for one which will serve this request's needs
     
    8180    }
    8281
    83     abstract protected function load(); // returns bool|WP_Error
     82    /**
     83     * Loads image from $this->file into editor.
     84     *
     85     * @since 3.5.0
     86     * @access protected
     87     * @abstract
     88     *
     89     * @return boolean|WP_Error True if loaded; WP_Error on failure.
     90     */
     91    abstract protected function load();
     92
     93    /**
     94     * Saves current image to file.
     95     *
     96     * @since 3.5.0
     97     * @access public
     98     * @abstract
     99     *
     100     * @param string $destfilename
     101     * @param string $mime_type
     102     * @return array|WP_Error {'path'=>string, 'file'=>string, 'width'=>int, 'height'=>int, 'mime-type'=>string}
     103     */
    84104    abstract public function save( $destfilename = null, $mime_type = null );
    85105
    86106    /**
    87      * Implement all of the below to support natively used functions:
    88      *
    89      * public function resize( $max_w, $max_h, $crop = false )
    90      * public function multi_resize( $sizes )
    91      * public function crop( $src_x, $src_y, $src_w, $src_h, $dst_w = null, $dst_h = null, $src_abs = false )
    92      * public function rotate( $angle )
    93      * public function flip( $horz, $vert )
    94      * public function stream( $mime_type = null )
    95      */
     107     * Resizes current image.
     108     *
     109     * @since 3.5.0
     110     * @access public
     111     * @abstract
     112     *
     113     * @param int $max_w
     114     * @param int $max_h
     115     * @param boolean $crop
     116     * @return boolean|WP_Error
     117     */
     118    abstract public function resize( $max_w, $max_h, $crop = false );
     119
     120    /**
     121     * Processes current image and saves to disk
     122     * multiple sizes from single source.
     123     *
     124     * @since 3.5.0
     125     * @access public
     126     * @abstract
     127     *
     128     * @param array $sizes
     129     * @return array
     130     */
     131    abstract public function multi_resize( $sizes );
     132
     133    /**
     134     * Crops Image.
     135     *
     136     * @since 3.5.0
     137     * @access public
     138     * @abstract
     139     *
     140     * @param string|int $src The source file or Attachment ID.
     141     * @param int $src_x The start x position to crop from.
     142     * @param int $src_y The start y position to crop from.
     143     * @param int $src_w The width to crop.
     144     * @param int $src_h The height to crop.
     145     * @param int $dst_w Optional. The destination width.
     146     * @param int $dst_h Optional. The destination height.
     147     * @param boolean $src_abs Optional. If the source crop points are absolute.
     148     * @return boolean|WP_Error
     149     */
     150    abstract public function crop( $src_x, $src_y, $src_w, $src_h, $dst_w = null, $dst_h = null, $src_abs = false );
     151
     152    /**
     153     * Rotates current image counter-clockwise by $angle.
     154     *
     155     * @since 3.5.0
     156     * @access public
     157     * @abstract
     158     *
     159     * @param float $angle
     160     * @return boolean|WP_Error
     161     */
     162    abstract public function rotate( $angle );
     163
     164    /**
     165     * Flips current image.
     166     *
     167     * @since 3.5.0
     168     * @access public
     169     * @abstract
     170     *
     171     * @param boolean $horz Horizonal Flip
     172     * @param boolean $vert Vertical Flip
     173     * @return boolean|WP_Error
     174     */
     175    abstract public function flip( $horz, $vert );
     176
     177    /**
     178     * Streams current image to browser.
     179     *
     180     * @since 3.5.0
     181     * @access public
     182     * @abstract
     183     *
     184     * @param string $mime_type
     185     * @return boolean|WP_Error
     186     */
     187    abstract public function stream( $mime_type = null );
    96188
    97189    /**
     
    111203
    112204    /**
    113      * Checks to see if editor supports mime-type specified
     205     * Checks to see if editor supports the mime-type specified.
    114206     * Must be overridden in a sub-class.
    115207     *
     
    126218
    127219    /**
    128      * Gets dimensions of image
     220     * Gets dimensions of image.
    129221     *
    130222     * @since 3.5.0
     
    138230
    139231    /**
    140      * Sets current image size
     232     * Sets current image size.
    141233     *
    142234     * @since 3.5.0
Note: See TracChangeset for help on using the changeset viewer.