Fix image_resize() dependencies by moving wp_load_image() from admin includes to wp-includes. Fixes #7279
git-svn-id: http://svn.automattic.com/wordpress/trunk@13860 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
32c90a6883
commit
bf6510abd1
|
@ -137,34 +137,6 @@ function wp_generate_attachment_metadata( $attachment_id, $file ) {
|
||||||
return apply_filters( 'wp_generate_attachment_metadata', $metadata, $attachment_id );
|
return apply_filters( 'wp_generate_attachment_metadata', $metadata, $attachment_id );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Load an image from a string, if PHP supports it.
|
|
||||||
*
|
|
||||||
* @since 2.1.0
|
|
||||||
*
|
|
||||||
* @param string $file Filename of the image to load.
|
|
||||||
* @return resource The resulting image resource on success, Error string on failure.
|
|
||||||
*/
|
|
||||||
function wp_load_image( $file ) {
|
|
||||||
if ( is_numeric( $file ) )
|
|
||||||
$file = get_attached_file( $file );
|
|
||||||
|
|
||||||
if ( ! file_exists( $file ) )
|
|
||||||
return sprintf(__('File “%s” doesn’t exist?'), $file);
|
|
||||||
|
|
||||||
if ( ! function_exists('imagecreatefromstring') )
|
|
||||||
return __('The GD image library is not installed.');
|
|
||||||
|
|
||||||
// Set artificially high because GD uses uncompressed images in memory
|
|
||||||
@ini_set('memory_limit', '256M');
|
|
||||||
$image = imagecreatefromstring( file_get_contents( $file ) );
|
|
||||||
|
|
||||||
if ( !is_resource( $image ) )
|
|
||||||
return sprintf(__('File “%s” is not an image.'), $file);
|
|
||||||
|
|
||||||
return $image;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculated the new dimentions for a downsampled image.
|
* Calculated the new dimentions for a downsampled image.
|
||||||
*
|
*
|
||||||
|
|
|
@ -230,6 +230,34 @@ function get_image_tag($id, $alt, $title, $align, $size='medium') {
|
||||||
return $html;
|
return $html;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load an image from a string, if PHP supports it.
|
||||||
|
*
|
||||||
|
* @since 2.1.0
|
||||||
|
*
|
||||||
|
* @param string $file Filename of the image to load.
|
||||||
|
* @return resource The resulting image resource on success, Error string on failure.
|
||||||
|
*/
|
||||||
|
function wp_load_image( $file ) {
|
||||||
|
if ( is_numeric( $file ) )
|
||||||
|
$file = get_attached_file( $file );
|
||||||
|
|
||||||
|
if ( ! file_exists( $file ) )
|
||||||
|
return sprintf(__('File “%s” doesn’t exist?'), $file);
|
||||||
|
|
||||||
|
if ( ! function_exists('imagecreatefromstring') )
|
||||||
|
return __('The GD image library is not installed.');
|
||||||
|
|
||||||
|
// Set artificially high because GD uses uncompressed images in memory
|
||||||
|
@ini_set('memory_limit', '256M');
|
||||||
|
$image = imagecreatefromstring( file_get_contents( $file ) );
|
||||||
|
|
||||||
|
if ( !is_resource( $image ) )
|
||||||
|
return sprintf(__('File “%s” is not an image.'), $file);
|
||||||
|
|
||||||
|
return $image;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculates the new dimentions for a downsampled image.
|
* Calculates the new dimentions for a downsampled image.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue