# _load_image_to_edit_path()

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

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

## Сигнатура

```php
_load_image_to_edit_path( int $attachment_id, string|int[] $size = 'full' ): string|false
```

## Описание

Если прикреплённый файл отсутствует в локальной файловой системе (обычно из-за плагинов репликации), возвращается URL файла, при условии что поддерживается allow_url_fopen.

## Параметры

- `$attachment_id` `int` — обязательный. Идентификатор вложения.
- `$size` `string|int[]` — необязательный, по умолчанию `'full'`. Размер изображения. Принимает имя любого зарегистрированного размера изображения или массив значений ширины и высоты в пикселях (именно в таком порядке). Значение по умолчанию 'full'.

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

`string|false`

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

Файл: `wp-admin/includes/image.php:1270`

```php
function _load_image_to_edit_path( $attachment_id, $size = 'full' ) {
	$filepath = get_attached_file( $attachment_id );

	if ( $filepath && file_exists( $filepath ) ) {
		if ( 'full' !== $size ) {
			$data = image_get_intermediate_size( $attachment_id, $size );

			if ( $data ) {
				$filepath = path_join( dirname( $filepath ), $data['file'] );

				/**
				 * Filters the path to an attachment's file when editing the image.
				 *
				 * The filter is evaluated for all image sizes except 'full'.
				 *
				 * @since 3.1.0
				 *
				 * @param string       $path          Path to the current image.
				 * @param int          $attachment_id Attachment ID.
				 * @param string|int[] $size          Requested image size. Can be any registered image size name, or
				 *                                    an array of width and height values in pixels (in that order).
				 */
				$filepath = apply_filters( 'load_image_to_edit_filesystempath', $filepath, $attachment_id, $size );
			}
		}
	} elseif ( function_exists( 'fopen' ) && ini_get( 'allow_url_fopen' ) ) {
		/**
		 * Filters the path to an attachment's URL when editing the image.
		 *
		 * The filter is only evaluated if the file isn't stored locally and `allow_url_fopen` is enabled on the server.
		 *
		 * @since 3.1.0
		 *
		 * @param string|false $image_url     Current image URL.
		 * @param int          $attachment_id Attachment ID.
		 * @param string|int[] $size          Requested image size. Can be any registered image size name, or
		 *                                    an array of width and height values in pixels (in that order).
		 */
		$filepath = apply_filters( 'load_image_to_edit_attachmenturl', wp_get_attachment_url( $attachment_id ), $attachment_id, $size );
	}

	/**
	 * Filters the returned path or URL of the current image.
	 *
	 * @since 2.9.0
	 *
	 * @param string|false $filepath      File path or URL to current image, or false.
	 * @param int          $attachment_id Attachment ID.
	 * @param string|int[] $size          Requested image size. Can be any registered image size name, or
	 *                                    an array of width and height values in pixels (in that order).
	 */
	return apply_filters( 'load_image_to_edit_path', $filepath, $attachment_id, $size );
}
```

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

- 3.4.0 — Introduced.

## Связанные

Использует: [`path_join`](https://chugunov.pro/api-wordpress/functions/path_join/), [`image_get_intermediate_size`](https://chugunov.pro/api-wordpress/functions/image_get_intermediate_size/), [`wp_get_attachment_url`](https://chugunov.pro/api-wordpress/functions/wp_get_attachment_url/), [`get_attached_file`](https://chugunov.pro/api-wordpress/functions/get_attached_file/), [`apply_filters`](https://chugunov.pro/api-wordpress/functions/apply_filters/).
Используется в: `WP_REST_Attachments_Controller::edit_media_item`, [`stream_preview_image`](https://chugunov.pro/api-wordpress/functions/stream_preview_image/), [`wp_save_image`](https://chugunov.pro/api-wordpress/functions/wp_save_image/), [`_copy_image_file`](https://chugunov.pro/api-wordpress/functions/_copy_image_file/), [`load_image_to_edit`](https://chugunov.pro/api-wordpress/functions/load_image_to_edit/), [`wp_crop_image`](https://chugunov.pro/api-wordpress/functions/wp_crop_image/).

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