From d1dc20712875525efed82848f9aa800c8a0938f9 Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Tue, 7 Jul 2020 16:51:04 +0000 Subject: [PATCH] Media, REST API: Allow media edit endpoint to find remote files. Props jonsurrell. Fixes #50595. Built from https://develop.svn.wordpress.org/trunk@48386 git-svn-id: http://core.svn.wordpress.org/trunk@48155 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- .../endpoints/class-wp-rest-attachments-controller.php | 10 +++++++++- wp-includes/version.php | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php b/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php index 9073df73a2..f46357c054 100644 --- a/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php +++ b/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php @@ -460,7 +460,15 @@ class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller { ); } - $image_editor = wp_get_image_editor( $image_file ); + // If the file doesn't exist, attempt a URL fopen on the src link. + // This can occur with certain file replication plugins. + // Keep the original file path to get a modified name later. + $image_file_to_edit = $image_file; + if ( ! file_exists( $image_file_to_edit ) ) { + $image_file_to_edit = _load_image_to_edit_path( $attachment_id ); + } + + $image_editor = wp_get_image_editor( $image_file_to_edit ); if ( is_wp_error( $image_editor ) ) { return new WP_Error( diff --git a/wp-includes/version.php b/wp-includes/version.php index 7205098a47..5a945c4842 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.5-alpha-48385'; +$wp_version = '5.5-alpha-48386'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.