]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/class-wp-image-editor-gd.php
Wordpress 3.6
[autoinstalls/wordpress.git] / wp-includes / class-wp-image-editor-gd.php
index b0781b572d6542c8b190c1c559d5eff4f8ea8152..12aaece1eb1cd5f83b559994777330987b23af37 100644 (file)
@@ -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 ( ! $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'];
 
                $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.
         *
         * 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
         *
         * @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 ) {
         * @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 ) {
                $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 ) ) {
                        $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
         *
         * @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 ) {
         * @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 );
                }
        }
                                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 );
+       }
 }
 }