WordPress Version: 4.4
/**
* Load an image from a string, if PHP supports it.
*
* @since 2.1.0
* @deprecated 3.5.0 Use wp_get_image_editor()
* @see wp_get_image_editor()
*
* @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)
{
_deprecated_function(__FUNCTION__, '3.5', 'wp_get_image_editor()');
if (is_numeric($file)) {
$file = get_attached_file($file);
}
if (!is_file($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', apply_filters('image_memory_limit', WP_MAX_MEMORY_LIMIT));
$image = imagecreatefromstring(file_get_contents($file));
if (!is_resource($image)) {
return sprintf(__('File “%s” is not an image.'), $file);
}
return $image;
}