* @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 )
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 ) )
$this->update_size( $size[0], $size[1] );
$this->mime_type = $size['mime'];
- return true;
+ return $this->set_quality( $this->quality );
}
/**
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 {
$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,
);
}