# wp_get_image_editor()

URL: https://chugunov.pro/api-wordpress/functions/wp_get_image_editor/
Проверено на WordPress 6.9, обновлено 06.08.2026.
Источник: независимый русскоязычный справочник chugunov.pro. Не является официальной документацией WordPress.

Тип: функция.
Появился в версии: 3.5.0.

## Сигнатура

```php
wp_get_image_editor( string $path, array $args = array() ): WP_Image_Editor|WP_Error
```

## Описание

Возвращает экземпляр WP_Image_Editor и загружает в него файл.

## Параметры

- `$path` `string` — обязательный. Путь к загружаемому файлу.
- `$args` `array` — необязательный, по умолчанию `array()`. Дополнительные аргументы для получения редактора изображений.

## Возвращаемое значение

`WP_Image_Editor|WP_Error` — WP_Image_Editor WP_Error

## Исходный код

Файл: `wp-includes/media.php:4214`

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

	// If the mime type is not set in args, try to extract and set it from the file.
	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'];
		}
	}

	// Check and set the output mime type mapped to the input type.
	if ( isset( $args['mime_type'] ) ) {
		$output_format = wp_get_image_editor_output_format( $path, $args['mime_type'] );
		if ( isset( $output_format[ $args['mime_type'] ] ) ) {
			$args['output_mime_type'] = $output_format[ $args['mime_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.' ) );
}
```

## История изменений

- 3.5.0 — Introduced.

## Связанные

Использует: [`wp_get_image_editor_output_format`](https://chugunov.pro/api-wordpress/functions/wp_get_image_editor_output_format/), [`wp_check_filetype`](https://chugunov.pro/api-wordpress/functions/wp_check_filetype/), [`__`](https://chugunov.pro/api-wordpress/functions/__/), [`is_wp_error`](https://chugunov.pro/api-wordpress/functions/is_wp_error/), `WP_Error::__construct`.
Используется в: [`wp_getimagesize`](https://chugunov.pro/api-wordpress/functions/wp_getimagesize/), `WP_REST_Attachments_Controller::edit_media_item`, [`wp_create_image_subsizes`](https://chugunov.pro/api-wordpress/functions/wp_create_image_subsizes/), [`_wp_make_subsizes`](https://chugunov.pro/api-wordpress/functions/_wp_make_subsizes/), [`stream_preview_image`](https://chugunov.pro/api-wordpress/functions/stream_preview_image/), [`wp_save_image`](https://chugunov.pro/api-wordpress/functions/wp_save_image/), [`wp_generate_attachment_metadata`](https://chugunov.pro/api-wordpress/functions/wp_generate_attachment_metadata/), [`wp_crop_image`](https://chugunov.pro/api-wordpress/functions/wp_crop_image/), [`image_resize`](https://chugunov.pro/api-wordpress/functions/image_resize/), [`image_make_intermediate_size`](https://chugunov.pro/api-wordpress/functions/image_make_intermediate_size/).

Оригинал в официальной документации: https://developer.wordpress.org/reference/functions/wp_get_image_editor/
