WordPress.org

Make WordPress Core

Ticket #12481: wp_load_image.not-available.12481.diff

File wp_load_image.not-available.12481.diff, 2.3 KB (added by filosofo, 4 years ago)
  • wp-includes/media.php

     
    413413} 
    414414 
    415415/** 
     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 */ 
     423function 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/** 
    416444 * Resize an image to make a thumbnail or intermediate size. 
    417445 * 
    418446 * The returned array has the file size, the image width, and image height. The 
  • wp-admin/includes/image.php

     
    138138} 
    139139 
    140140/** 
    141  * Load an image from a string, if PHP supports it. 
    142  * 
    143  * @since 2.1.0 
    144  * 
    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 memory 
    159         @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 /** 
    169141 * Calculated the new dimentions for a downsampled image. 
    170142 * 
    171143 * @since 2.0.0