Warning: This function has been deprecated. Use wp_get_image_editor() instead.

wp_load_image() WordPress Function

The wp_load_image() function loads an image from a file. This function is used by the media uploader in WordPress.

wp_load_image( string $file ) #

Load an image from a string, if PHP supports it.


Description

Top ↑

See also


Top ↑

Parameters

$file

(string)(Required)Filename of the image to load.


Top ↑

Return

(resource|GdImage|string) The resulting image resource or GdImage instance on success, error string on failure.


Top ↑

Source

File: wp-includes/deprecated.php

function wp_load_image( $file ) {
	_deprecated_function( __FUNCTION__, '3.5.0', 'wp_get_image_editor()' );

	if ( is_numeric( $file ) )
		$file = get_attached_file( $file );

	if ( ! is_file( $file ) ) {
		/* translators: %s: File name. */
		return sprintf( __( 'File “%s” does not exist?' ), $file );
	}

	if ( ! function_exists('imagecreatefromstring') )
		return __('The GD image library is not installed.');

	// Set artificially high because GD uses uncompressed images in memory.
	wp_raise_memory_limit( 'image' );

	$image = imagecreatefromstring( file_get_contents( $file ) );

	if ( ! is_gd_image( $image ) ) {
		/* translators: %s: File name. */
		return sprintf( __( 'File “%s” is not an image.' ), $file );
	}

	return $image;
}


Top ↑

Changelog

Changelog
VersionDescription
3.5.0Use wp_get_image_editor()
2.1.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More