Skip to content

Commit

Permalink
Try loading remote image if local is not present (#23742)
Browse files Browse the repository at this point in the history
  • Loading branch information
sirreal authored and youknowriad committed Jul 9, 2020
1 parent 1e095fd commit 1f57f61
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/class-wp-rest-image-editor-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,15 @@ public function apply_edits( $request ) {
return new WP_Error( 'rest_image_not_edited', $error, array( 'status' => 400 ) );
}

$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 ) ) {
// This image cannot be edited.
Expand Down

0 comments on commit 1f57f61

Please sign in to comment.