Ticket #12481: wp_load_image.not-available.12481.diff
| File wp_load_image.not-available.12481.diff, 2.3 KB (added by , 16 years ago) |
|---|
-
wp-includes/media.php
413 413 } 414 414 415 415 /** 416 * Load an image from a string, if PHP supports it. 417 * 418 * @since 2.1.0 419 * 420 * @param string $file Filename of the image to load. 421 * @return resource The resulting image resource on success, Error string on failure. 422 */ 423 function wp_load_image( $file ) { 424 if ( is_numeric( $file ) ) 425 $file = get_attached_file( $file ); 426 427 if ( ! file_exists( $file ) ) 428 return sprintf(__('File “%s” doesn’t exist?'), $file); 429 430 if ( ! function_exists('imagecreatefromstring') ) 431 return __('The GD image library is not installed.'); 432 433 // Set artificially high because GD uses uncompressed images in memory 434 @ini_set('memory_limit', '256M'); 435 $image = imagecreatefromstring( file_get_contents( $file ) ); 436 437 if ( !is_resource( $image ) ) 438 return sprintf(__('File “%s” is not an image.'), $file); 439 440 return $image; 441 } 442 443 /** 416 444 * Resize an image to make a thumbnail or intermediate size. 417 445 * 418 446 * The returned array has the file size, the image width, and image height. The -
wp-admin/includes/image.php
138 138 } 139 139 140 140 /** 141 * Load an image from a string, if PHP supports it.142 *143 * @since 2.1.0144 *145 * @param string $file Filename of the image to load.146 * @return resource The resulting image resource on success, Error string on failure.147 */148 function wp_load_image( $file ) {149 if ( is_numeric( $file ) )150 $file = get_attached_file( $file );151 152 if ( ! file_exists( $file ) )153 return sprintf(__('File “%s” doesn’t exist?'), $file);154 155 if ( ! function_exists('imagecreatefromstring') )156 return __('The GD image library is not installed.');157 158 // Set artificially high because GD uses uncompressed images in memory159 @ini_set('memory_limit', '256M');160 $image = imagecreatefromstring( file_get_contents( $file ) );161 162 if ( !is_resource( $image ) )163 return sprintf(__('File “%s” is not an image.'), $file);164 165 return $image;166 }167 168 /**169 141 * Calculated the new dimentions for a downsampled image. 170 142 * 171 143 * @since 2.0.0