WordPress at a glance

wp_get_image_editor() WP 1.0

Returns a WP_Image_Editor instance and loads file into it.

No Hooks.

Return

WP_Image_Editor/WP_Error. The WP_Image_Editor object if successful, an WP_Error object otherwise.

Usage

wp_get_image_editor( $path, $args );
$path(string) (required)
Path to the file to load.
$args(array)
Additional arguments for retrieving the image editor.
Default: empty array

Code of wp_get_image_editor: wp-includes/media.php VER 4.9.8

<?php
function wp_get_image_editor( $path, $args = array() ) {
	$args['path'] = $path;

	if ( ! isset( $args['mime_type'] ) ) {
		$file_info = wp_check_filetype( $args['path'] );

		// If $file_info['type'] is false, then we let the editor attempt to
		// figure out the file type, rather than forcing a failure based on extension.
		if ( isset( $file_info ) && $file_info['type'] )
			$args['mime_type'] = $file_info['type'];
	}

	$implementation = _wp_image_editor_choose( $args );

	if ( $implementation ) {
		$editor = new $implementation( $path );
		$loaded = $editor->load();

		if ( is_wp_error( $loaded ) )
			return $loaded;

		return $editor;
	}

	return new WP_Error( 'image_no_editor', __('No editor could be selected.') );
}

Related Functions

From tag: Thumbnail (images)

More from category: Thumbnails

No comments
    Hello, !     Log In . Register