Make WordPress Core


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

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.