X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/baca9ce86a38dc54c4574890ee2d352fd81f78b2..61343b82c4f0da4c68e4c6373daafff4a81efdd1:/wp-includes/class-wp-image-editor-gd.php diff --git a/wp-includes/class-wp-image-editor-gd.php b/wp-includes/class-wp-image-editor-gd.php index b0781b57..12aaece1 100644 --- a/wp-includes/class-wp-image-editor-gd.php +++ b/wp-includes/class-wp-image-editor-gd.php @@ -97,6 +97,11 @@ class WP_Image_Editor_GD extends WP_Image_Editor { if ( ! $size ) return new WP_Error( 'invalid_image', __('Could not read image size.'), $this->file ); + if ( function_exists( 'imagealphablending' ) && function_exists( 'imagesavealpha' ) ) { + imagealphablending( $this->image, false ); + imagesavealpha( $this->image, true ); + } + $this->update_size( $size[0], $size[1] ); $this->mime_type = $size['mime']; @@ -173,10 +178,13 @@ class WP_Image_Editor_GD extends WP_Image_Editor { * Processes current image and saves to disk * multiple sizes from single source. * + * 'width' and 'height' are required. + * 'crop' defaults to false when not provided. + * * @since 3.5.0 * @access public * - * @param array $sizes { {'width'=>int, 'height'=>int, 'crop'=>bool}, ... } + * @param array $sizes { {'width'=>int, 'height'=>int, ['crop'=>bool]}, ... } * @return array */ public function multi_resize( $sizes ) { @@ -184,6 +192,12 @@ class WP_Image_Editor_GD extends WP_Image_Editor { $orig_size = $this->size; foreach ( $sizes as $size => $size_data ) { + if ( ! ( isset( $size_data['width'] ) && isset( $size_data['height'] ) ) ) + continue; + + if ( ! isset( $size_data['crop'] ) ) + $size_data['crop'] = false; + $image = $this->_resize( $size_data['width'], $size_data['height'], $size_data['crop'] ); if( ! is_wp_error( $image ) ) { @@ -279,8 +293,8 @@ class WP_Image_Editor_GD extends WP_Image_Editor { * @since 3.5.0 * @access public * - * @param boolean $horz Horizontal Flip - * @param boolean $vert Vertical Flip + * @param boolean $horz Flip along Horizontal Axis + * @param boolean $vert Flip along Vertical Axis * @returns boolean|WP_Error */ public function flip( $horz, $vert ) { @@ -387,4 +401,22 @@ class WP_Image_Editor_GD extends WP_Image_Editor { return imagejpeg( $this->image, null, $this->quality ); } } + + /** + * Either calls editor's save function or handles file as a stream. + * + * @since 3.5.0 + * @access protected + * + * @param string|stream $filename + * @param callable $function + * @param array $arguments + * @return boolean + */ + protected function make_image( $filename, $function, $arguments ) { + if ( wp_is_stream( $filename ) ) + $arguments[1] = null; + + return parent::make_image( $filename, $function, $arguments ); + } }