diff --git a/src/wp-admin/includes/media.php b/src/wp-admin/includes/media.php
index cfc80db8ea..0703dc2257 100644
a
|
b
|
function media_sideload_image( $file, $post_id, $desc = null, $return = 'html' ) |
924 | 924 | // Set variables for storage, fix file filename for query strings. |
925 | 925 | preg_match( '/[^\?]+\.(jpe?g|jpe|gif|png)\b/i', $file, $matches ); |
926 | 926 | if ( ! $matches ) { |
927 | | return new WP_Error( 'image_sideload_failed', __( 'Invalid image URL' ) ); |
| 927 | $extension = wp_get_image_mime( $file ); |
| 928 | if ( $extension !== false ) { |
| 929 | if ( preg_match( '/(jpe?g|jpe|gif|png)/i', $extension, $ext_matches ) ) { |
| 930 | $matches = array( '.' . $ext_matches[0] ); |
| 931 | } |
| 932 | } else { |
| 933 | return new WP_Error( 'image_sideload_failed', __( 'Invalid image URL' ) ); |
| 934 | } |
928 | 935 | } |
929 | 936 | |
930 | 937 | $file_array = array(); |