diff --git a/wp-admin/includes/image.php b/wp-admin/includes/image.php index 3591231787..5e9cfd1361 100644 --- a/wp-admin/includes/image.php +++ b/wp-admin/includes/image.php @@ -22,13 +22,15 @@ * @param string $dst_file Optional. The destination file to write to. * @return string|WP_Error|false New filepath on success, WP_Error or false on failure. */ -function wp_crop_image( $src_file, $src_x, $src_y, $src_w, $src_h, $dst_w, $dst_h, $src_abs = false, $dst_file = false ) { - if ( is_numeric( $src_file ) ) { // Handle int as attachment ID - $src_file = get_attached_file( $src_file ); +function wp_crop_image( $src, $src_x, $src_y, $src_w, $src_h, $dst_w, $dst_h, $src_abs = false, $dst_file = false ) { + $src_file = $src; + if ( is_numeric( $src ) ) { // Handle int as attachment ID + $src_file = get_attached_file( $src ); + if ( ! file_exists( $src_file ) ) { // If the file doesn't exist, attempt a url fopen on the src link. // This can occur with certain file replication plugins. - $src_file = _load_image_to_edit_path( $src_file, 'full' ); + $src_file = _load_image_to_edit_path( $src, 'full' ); } } diff --git a/wp-includes/class-wp-image-editor-gd.php b/wp-includes/class-wp-image-editor-gd.php index dcd1644733..3e7e43f5b2 100644 --- a/wp-includes/class-wp-image-editor-gd.php +++ b/wp-includes/class-wp-image-editor-gd.php @@ -51,7 +51,7 @@ class WP_Image_Editor_GD extends WP_Image_Editor { if ( $this->image ) return true; - if ( ! is_file( $this->file ) ) + if ( ! is_file( $this->file ) && ! preg_match( '|^https?://|', $this->file ) ) return new WP_Error( 'error_loading_image', __('File doesn’t exist?'), $this->file ); // Set artificially high because GD uses uncompressed images in memory diff --git a/wp-includes/class-wp-image-editor-imagick.php b/wp-includes/class-wp-image-editor-imagick.php index c3372d35b3..c748a22676 100644 --- a/wp-includes/class-wp-image-editor-imagick.php +++ b/wp-includes/class-wp-image-editor-imagick.php @@ -52,7 +52,7 @@ class WP_Image_Editor_Imagick extends WP_Image_Editor { if ( $this->image ) return true; - if ( ! is_file( $this->file ) ) + if ( ! is_file( $this->file ) && ! preg_match( '|^https?://|', $this->file ) ) return new WP_Error( 'error_loading_image', __('File doesn’t exist?'), $this->file ); try {