]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/class-wp-image-editor-gd.php
WordPress 3.8.3
[autoinstalls/wordpress.git] / wp-includes / class-wp-image-editor-gd.php
index a8235c241dabbd5590939d0f03a4b86c7e993f02..fdd55868665c51fc296e7742232f2e52535e3619 100644 (file)
@@ -77,7 +77,7 @@ class WP_Image_Editor_GD extends WP_Image_Editor {
         * @since 3.5.0
         * @access protected
         *
-        * @return boolean|\WP_Error
+        * @return boolean|WP_Error True if loaded successfully; WP_Error on failure.
         */
        public function load() {
                if ( $this->image )
@@ -86,8 +86,17 @@ class WP_Image_Editor_GD extends WP_Image_Editor {
                if ( ! is_file( $this->file ) && ! preg_match( '|^https?://|', $this->file ) )
                        return new WP_Error( 'error_loading_image', __('File doesn’t exist?'), $this->file );
 
+               /**
+                * Filter the memory limit allocated for image manipulation.
+                *
+                * @since 3.5.0
+                *
+                * @param int|string $limit Maximum memory limit to allocate for images. Default WP_MAX_MEMORY_LIMIT.
+                *                          Accepts an integer (bytes), or a shorthand string notation, such as '256M'.
+                */
                // Set artificially high because GD uses uncompressed images in memory
                @ini_set( 'memory_limit', apply_filters( 'image_memory_limit', WP_MAX_MEMORY_LIMIT ) );
+
                $this->image = @imagecreatefromstring( file_get_contents( $this->file ) );
 
                if ( ! is_resource( $this->image ) )
@@ -105,7 +114,7 @@ class WP_Image_Editor_GD extends WP_Image_Editor {
                $this->update_size( $size[0], $size[1] );
                $this->mime_type = $size['mime'];
 
-               return true;
+               return $this->set_quality( $this->quality );
        }
 
        /**
@@ -361,7 +370,7 @@ class WP_Image_Editor_GD extends WP_Image_Editor {
                                return new WP_Error( 'image_save_error', __('Image Editor Save Failed') );
                }
                elseif ( 'image/jpeg' == $mime_type ) {
-                       if ( ! $this->make_image( $filename, 'imagejpeg', array( $image, $filename, apply_filters( 'jpeg_quality', $this->quality, 'image_resize' ) ) ) )
+                       if ( ! $this->make_image( $filename, 'imagejpeg', array( $image, $filename, $this->quality ) ) )
                                return new WP_Error( 'image_save_error', __('Image Editor Save Failed') );
                }
                else {
@@ -373,12 +382,19 @@ class WP_Image_Editor_GD extends WP_Image_Editor {
                $perms = $stat['mode'] & 0000666; //same permissions as parent folder, strip off the executable bits
                @ chmod( $filename, $perms );
 
+               /**
+                * Filter the name of the saved image file.
+                *
+                * @since 2.6.0
+                *
+                * @param string $filename Name of the file.
+                */
                return array(
-                       'path' => $filename,
-                       'file' => wp_basename( apply_filters( 'image_make_intermediate_size', $filename ) ),
-                       'width' => $this->size['width'],
-                       'height' => $this->size['height'],
-                       'mime-type'=> $mime_type,
+                       'path'      => $filename,
+                       'file'      => wp_basename( apply_filters( 'image_make_intermediate_size', $filename ) ),
+                       'width'     => $this->size['width'],
+                       'height'    => $this->size['height'],
+                       'mime-type' => $mime_type,
                );
        }