X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/fa11948979fd6a4ea5705dc613b239699a459db3..256a3b381f63716209b3527d0a14442ae570c283:/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 a8235c24..fdd55868 100644 --- a/wp-includes/class-wp-image-editor-gd.php +++ b/wp-includes/class-wp-image-editor-gd.php @@ -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, ); }