diff --git a/wp-includes/class-wp-image-editor-gd.php b/wp-includes/class-wp-image-editor-gd.php index 3e7e43f5b2..ca76006d57 100644 --- a/wp-includes/class-wp-image-editor-gd.php +++ b/wp-includes/class-wp-image-editor-gd.php @@ -25,7 +25,7 @@ class WP_Image_Editor_GD extends WP_Image_Editor { } /** - * Checks to see if current environment supports GD + * Checks to see if current environment supports GD. * * @since 3.5.0 * @access public @@ -40,9 +40,9 @@ class WP_Image_Editor_GD extends WP_Image_Editor { } /** - * Loads image from $this->file into new GD Resource + * Loads image from $this->file into new GD Resource. * - * @since 3.5 + * @since 3.5.0 * @access protected * * @return boolean|\WP_Error @@ -72,7 +72,7 @@ class WP_Image_Editor_GD extends WP_Image_Editor { } /** - * Sets or updates current image size + * Sets or updates current image size. * * @since 3.5.0 * @access protected @@ -91,7 +91,7 @@ class WP_Image_Editor_GD extends WP_Image_Editor { } /** - * Checks to see if editor supports mime-type specified + * Checks to see if editor supports the mime-type specified. * * @since 3.5.0 * @access public @@ -107,7 +107,10 @@ class WP_Image_Editor_GD extends WP_Image_Editor { /** * Resizes current image. - * Wrapper around _resize, since _resize returns a GD Resource + * Wraps _resize, since _resize returns a GD Resource. + * + * @since 3.5.0 + * @access public * * @param int $max_w * @param int $max_h @@ -153,6 +156,9 @@ class WP_Image_Editor_GD extends WP_Image_Editor { * Processes current image and saves to disk * multiple sizes from single source. * + * @since 3.5.0 + * @access public + * * @param array $sizes { {width, height}, ... } * @return array */ @@ -192,7 +198,7 @@ class WP_Image_Editor_GD extends WP_Image_Editor { * @param int $src_h The height to crop. * @param int $dst_w Optional. The destination width. * @param int $dst_h Optional. The destination height. - * @param int $src_abs Optional. If the source crop points are absolute. + * @param boolean $src_abs Optional. If the source crop points are absolute. * @return boolean|WP_Error */ public function crop( $src_x, $src_y, $src_w, $src_h, $dst_w = null, $dst_h = null, $src_abs = false ) { @@ -250,7 +256,10 @@ class WP_Image_Editor_GD extends WP_Image_Editor { } /** - * Flips current image + * Flips current image. + * + * @since 3.5.0 + * @access public * * @param boolean $horz Horizonal Flip * @param boolean $vert Vertical Flip @@ -277,7 +286,10 @@ class WP_Image_Editor_GD extends WP_Image_Editor { } /** - * Saves current in-memory image to file + * Saves current in-memory image to file. + * + * @since 3.5.0 + * @access public * * @param string $destfilename * @param string $mime_type @@ -335,7 +347,10 @@ class WP_Image_Editor_GD extends WP_Image_Editor { } /** - * Returns stream of current image + * Returns stream of current image. + * + * @since 3.5.0 + * @access public * * @param string $mime_type */ diff --git a/wp-includes/class-wp-image-editor-imagick.php b/wp-includes/class-wp-image-editor-imagick.php index 1f137fd959..601b99b1b7 100644 --- a/wp-includes/class-wp-image-editor-imagick.php +++ b/wp-includes/class-wp-image-editor-imagick.php @@ -44,7 +44,7 @@ class WP_Image_Editor_Imagick extends WP_Image_Editor { } /** - * Loads image from $this->file into new Imagick Object + * Loads image from $this->file into new Imagick Object. * * @since 3.5.0 * @access protected @@ -109,7 +109,7 @@ class WP_Image_Editor_Imagick extends WP_Image_Editor { } /** - * Sets or updates current image size + * Sets or updates current image size. * * @since 3.5.0 * @access protected @@ -138,7 +138,7 @@ class WP_Image_Editor_Imagick extends WP_Image_Editor { } /** - * Checks to see if editor supports mime-type specified + * Checks to see if editor supports the mime-type specified. * * @since 3.5.0 * @access public @@ -163,6 +163,9 @@ class WP_Image_Editor_Imagick extends WP_Image_Editor { /** * Resizes current image. * + * @since 3.5.0 + * @access public + * * @param int $max_w * @param int $max_h * @param boolean $crop @@ -199,6 +202,9 @@ class WP_Image_Editor_Imagick extends WP_Image_Editor { * Processes current image and saves to disk * multiple sizes from single source. * + * @since 3.5.0 + * @access public + * * @param array $sizes * @return array */ @@ -246,11 +252,10 @@ class WP_Image_Editor_Imagick extends WP_Image_Editor { * @param int $src_h The height to crop. * @param int $dst_w Optional. The destination width. * @param int $dst_h Optional. The destination height. - * @param int $src_abs Optional. If the source crop points are absolute. + * @param boolean $src_abs Optional. If the source crop points are absolute. * @return boolean|WP_Error */ public function crop( $src_x, $src_y, $src_w, $src_h, $dst_w = null, $dst_h = null, $src_abs = false ) { - // Not sure this is compatible. if ( $src_abs ) { $src_w -= $src_x; $src_h -= $src_y; @@ -302,14 +307,14 @@ class WP_Image_Editor_Imagick extends WP_Image_Editor { } /** - * Flips current image + * Flips current image. * * @since 3.5.0 * @access public * - * @param boolean $horz Horizontal Flip + * @param boolean $horz Horizonal Flip * @param boolean $vert Vertical Flip - * @returns boolean + * @returns boolean|WP_Error */ public function flip( $horz, $vert ) { try { @@ -326,7 +331,10 @@ class WP_Image_Editor_Imagick extends WP_Image_Editor { } /** - * Saves current image to file + * Saves current image to file. + * + * @since 3.5.0 + * @access public * * @param string $destfilename * @param string $mime_type @@ -385,7 +393,10 @@ class WP_Image_Editor_Imagick extends WP_Image_Editor { } /** - * Streams current image to browser + * Streams current image to browser. + * + * @since 3.5.0 + * @access public * * @param string $mime_type * @return boolean|WP_Error diff --git a/wp-includes/class-wp-image-editor.php b/wp-includes/class-wp-image-editor.php index 4c227a2686..920e4a464b 100644 --- a/wp-includes/class-wp-image-editor.php +++ b/wp-includes/class-wp-image-editor.php @@ -62,8 +62,7 @@ abstract class WP_Image_Editor { array( 'WP_Image_Editor_Imagick', 'WP_Image_Editor_GD' ) ); if ( ! $required_methods ) - $required_methods = apply_filters( 'wp_image_editor_default_methods', - array( 'resize', 'multi_resize', 'crop', 'rotate', 'flip', 'stream' ) ); + $required_methods = array(); // Loop over each editor on each request looking for one which will serve this request's needs foreach ( $request_order as $editor ) { @@ -80,19 +79,112 @@ abstract class WP_Image_Editor { return false; } - abstract protected function load(); // returns bool|WP_Error + /** + * Loads image from $this->file into editor. + * + * @since 3.5.0 + * @access protected + * @abstract + * + * @return boolean|WP_Error True if loaded; WP_Error on failure. + */ + abstract protected function load(); + + /** + * Saves current image to file. + * + * @since 3.5.0 + * @access public + * @abstract + * + * @param string $destfilename + * @param string $mime_type + * @return array|WP_Error {'path'=>string, 'file'=>string, 'width'=>int, 'height'=>int, 'mime-type'=>string} + */ abstract public function save( $destfilename = null, $mime_type = null ); /** - * Implement all of the below to support natively used functions: + * Resizes current image. * - * public function resize( $max_w, $max_h, $crop = false ) - * public function multi_resize( $sizes ) - * public function crop( $src_x, $src_y, $src_w, $src_h, $dst_w = null, $dst_h = null, $src_abs = false ) - * public function rotate( $angle ) - * public function flip( $horz, $vert ) - * public function stream( $mime_type = null ) + * @since 3.5.0 + * @access public + * @abstract + * + * @param int $max_w + * @param int $max_h + * @param boolean $crop + * @return boolean|WP_Error */ + abstract public function resize( $max_w, $max_h, $crop = false ); + + /** + * Processes current image and saves to disk + * multiple sizes from single source. + * + * @since 3.5.0 + * @access public + * @abstract + * + * @param array $sizes + * @return array + */ + abstract public function multi_resize( $sizes ); + + /** + * Crops Image. + * + * @since 3.5.0 + * @access public + * @abstract + * + * @param string|int $src The source file or Attachment ID. + * @param int $src_x The start x position to crop from. + * @param int $src_y The start y position to crop from. + * @param int $src_w The width to crop. + * @param int $src_h The height to crop. + * @param int $dst_w Optional. The destination width. + * @param int $dst_h Optional. The destination height. + * @param boolean $src_abs Optional. If the source crop points are absolute. + * @return boolean|WP_Error + */ + abstract public function crop( $src_x, $src_y, $src_w, $src_h, $dst_w = null, $dst_h = null, $src_abs = false ); + + /** + * Rotates current image counter-clockwise by $angle. + * + * @since 3.5.0 + * @access public + * @abstract + * + * @param float $angle + * @return boolean|WP_Error + */ + abstract public function rotate( $angle ); + + /** + * Flips current image. + * + * @since 3.5.0 + * @access public + * @abstract + * + * @param boolean $horz Horizonal Flip + * @param boolean $vert Vertical Flip + * @return boolean|WP_Error + */ + abstract public function flip( $horz, $vert ); + + /** + * Streams current image to browser. + * + * @since 3.5.0 + * @access public + * @abstract + * + * @param string $mime_type + * @return boolean|WP_Error + */ + abstract public function stream( $mime_type = null ); /** * Checks to see if current environment supports the editor chosen. @@ -110,7 +202,7 @@ abstract class WP_Image_Editor { } /** - * Checks to see if editor supports mime-type specified + * Checks to see if editor supports the mime-type specified. * Must be overridden in a sub-class. * * @since 3.5.0 @@ -125,7 +217,7 @@ abstract class WP_Image_Editor { } /** - * Gets dimensions of image + * Gets dimensions of image. * * @since 3.5.0 * @access public @@ -137,7 +229,7 @@ abstract class WP_Image_Editor { } /** - * Sets current image size + * Sets current image size. * * @since 3.5.0 * @access protected