WordPress.org

Make WordPress Core

Changeset 13860


Ignore:
Timestamp:
03/28/2010 03:39:00 AM (8 years ago)
Author:
dd32
Message:

Fix image_resize() dependencies by moving wp_load_image() from admin includes to wp-includes. Fixes #7279

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/image.php

    r13249 r13860  
    136136
    137137    return apply_filters( 'wp_generate_attachment_metadata', $metadata, $attachment_id );
    138 }
    139 
    140 /**
    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;
    166138}
    167139
  • trunk/wp-includes/media.php

    r13857 r13860  
    229229
    230230    return $html;
     231}
     232
     233/**
     234 * Load an image from a string, if PHP supports it.
     235 *
     236 * @since 2.1.0
     237 *
     238 * @param string $file Filename of the image to load.
     239 * @return resource The resulting image resource on success, Error string on failure.
     240 */
     241function wp_load_image( $file ) {
     242    if ( is_numeric( $file ) )
     243        $file = get_attached_file( $file );
     244
     245    if ( ! file_exists( $file ) )
     246        return sprintf(__('File “%s” doesn’t exist?'), $file);
     247
     248    if ( ! function_exists('imagecreatefromstring') )
     249        return __('The GD image library is not installed.');
     250
     251    // Set artificially high because GD uses uncompressed images in memory
     252    @ini_set('memory_limit', '256M');
     253    $image = imagecreatefromstring( file_get_contents( $file ) );
     254
     255    if ( !is_resource( $image ) )
     256        return sprintf(__('File “%s” is not an image.'), $file);
     257
     258    return $image;
    231259}
    232260
Note: See TracChangeset for help on using the changeset viewer.