Make WordPress Core

Changeset 22619

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

Add abstract methods back to WP_Image_Editor and refresh phpdoc.

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

Location:
trunk/wp-includes
Files:
3 edited

Legend:

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

    r22538 r22619  
    2626
    2727    /**
    28      * Checks to see if current environment supports GD
     28     * Checks to see if current environment supports GD
    2929     *
    3030     * @since 3.5.0
     
    4141
    4242    /**
    43      * Loads image from $this->file into new GD Resource
    44      *
    45      * @since 3.5
     43     * Loads image from $this->file into new GD Resource
     44     *
     45     * @since 3.5
    4646     * @access protected
    4747     *
     
    7373
    7474    /**
    75      * Sets or updates current image size
     75     * Sets or updates current image size
    7676     *
    7777     * @since 3.5.0
     
    9292
    9393    /**
    94      * Checks to see if editor supports mime-type specified
     94     * Checks to see if editor supports
    9595     *
    9696     * @since 3.5.0
     
    108108    /**
    109109     * Resizes current image.
    110      * Wrapper around _resize, since _resize returns a GD Resource
     110     * Wraps _resize, since _resize returns a GD Resource.
     111     *
     112     * @since 3.5.0
     113     * @access public
    111114     *
    112115     * @param int $max_w
     
    153156     * Processes current image and saves to disk
    154157     * multiple sizes from single source.
     158
     159
     160
    155161     *
    156162     * @param array $sizes { {width, height}, ... }
     
    193199     * @param int $dst_w Optional. The destination width.
    194200     * @param int $dst_h Optional. The destination height.
    195      * @param int $src_abs Optional. If the source crop points are absolute.
     201     * @param $src_abs Optional. If the source crop points are absolute.
    196202     * @return boolean|WP_Error
    197203     */
     
    251257
    252258    /**
    253      * Flips current image
     259     * Flips current image.
     260     *
     261     * @since 3.5.0
     262     * @access public
    254263     *
    255264     * @param boolean $horz Horizonal Flip
     
    278287
    279288    /**
    280      * Saves current in-memory image to file
     289     * Saves current in-memory image to file.
     290     *
     291     * @since 3.5.0
     292     * @access public
    281293     *
    282294     * @param string $destfilename
     
    336348
    337349    /**
    338      * Returns stream of current image
     350     * Returns stream of current image.
     351     *
     352     * @since 3.5.0
     353     * @access public
    339354     *
    340355     * @param string $mime_type
  • trunk/wp-includes/class-wp-image-editor-imagick.php

    r22581 r22619  
    4545
    4646    /**
    47      * Loads image from $this->file into new Imagick Object
     47     * Loads image from $this->file into new Imagick Object
    4848     *
    4949     * @since 3.5.0
     
    110110
    111111    /**
    112      * Sets or updates current image size
     112     * Sets or updates current image size
    113113     *
    114114     * @since 3.5.0
     
    139139
    140140    /**
    141      * Checks to see if editor supports mime-type specified
     141     * Checks to see if editor supports
    142142     *
    143143     * @since 3.5.0
     
    163163    /**
    164164     * Resizes current image.
     165
     166
     167
    165168     *
    166169     * @param int $max_w
     
    199202     * Processes current image and saves to disk
    200203     * multiple sizes from single source.
     204
     205
     206
    201207     *
    202208     * @param array $sizes
     
    247253     * @param int $dst_w Optional. The destination width.
    248254     * @param int $dst_h Optional. The destination height.
    249      * @param int $src_abs Optional. If the source crop points are absolute.
     255     * @param $src_abs Optional. If the source crop points are absolute.
    250256     * @return boolean|WP_Error
    251257     */
    252258    public function crop( $src_x, $src_y, $src_w, $src_h, $dst_w = null, $dst_h = null, $src_abs = false ) {
    253         // Not sure this is compatible.
    254259        if ( $src_abs ) {
    255260            $src_w -= $src_x;
     
    303308
    304309    /**
    305      * Flips current image
    306      *
    307      * @since 3.5.0
    308      * @access public
    309      *
    310      * @param boolean $horz Horizontal Flip
     310     * Flips current image
     311     *
     312     * @since 3.5.0
     313     * @access public
     314     *
     315     * @param boolean $horz Horizonal Flip
    311316     * @param boolean $vert Vertical Flip
    312      * @returns boolean
     317     * @returns boolean
    313318     */
    314319    public function flip( $horz, $vert ) {
     
    327332
    328333    /**
    329      * Saves current image to file
     334     * Saves current image to file.
     335     *
     336     * @since 3.5.0
     337     * @access public
    330338     *
    331339     * @param string $destfilename
     
    386394
    387395    /**
    388      * Streams current image to browser
     396     * Streams current image to browser.
     397     *
     398     * @since 3.5.0
     399     * @access public
    389400     *
    390401     * @param string $mime_type
  • 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
    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.