Skip to content

Instantly share code, notes, and snippets.

@kurtpayne
Created August 5, 2012 23:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kurtpayne/3267793 to your computer and use it in GitHub Desktop.
Save kurtpayne/3267793 to your computer and use it in GitHub Desktop.
21481.patch
Index: wp-admin/includes/image.php
===================================================================
--- wp-admin/includes/image.php (revision 21427)
+++ wp-admin/includes/image.php (working copy)
@@ -143,9 +143,11 @@
}
$sizes = apply_filters( 'intermediate_image_sizes_advanced', $sizes );
+
+ $image = wp_load_image( $file );
foreach ($sizes as $size => $size_data ) {
- $resized = image_make_intermediate_size( $file, $size_data['width'], $size_data['height'], $size_data['crop'] );
+ $resized = image_make_intermediate_size( $image, $size_data['width'], $size_data['height'], $size_data['crop'] );
if ( $resized )
$metadata['sizes'][$size] = $resized;
}
Index: wp-includes/media.php
===================================================================
--- wp-includes/media.php (revision 21427)
+++ wp-includes/media.php (working copy)
@@ -405,7 +405,7 @@
*
* @since 2.5.0
*
- * @param string $file Image file path.
+ * @param string|resource $file Image file path or open file resource
* @param int $max_w Maximum width to resize to.
* @param int $max_h Maximum height to resize to.
* @param bool $crop Optional. Whether to crop image or resize.
@@ -416,7 +416,10 @@
*/
function image_resize( $file, $max_w, $max_h, $crop = false, $suffix = null, $dest_path = null, $jpeg_quality = 90 ) {
- $image = wp_load_image( $file );
+ if ( is_resource( $file ) )
+ $image = $file;
+ else
+ $image = wp_load_image( $file );
if ( !is_resource( $image ) )
return new WP_Error( 'error_loading_image', $image, $file );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment