#49944 closed enhancement (duplicate)
media_sideload_image() fails with no file extension.
| Reported by: | secondlinethemes | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Media | Version: | 5.4 |
| Severity: | minor | Keywords: | needs-patch |
| Cc: | Focuses: |
Description
The media_sideload_image() function is only able to use paths with full file extensions (i.e - https://example.com/img/image.jpg). However, if a valid image is based in a URL with no extension, it fails. (i.e. - https://example.com/img/image)
The extension-less URL can still have a valid image content-type header for the image. It fails twice, both in the regex test -
preg_match( '/[^\?]+\.(jpe?g|jpe|gif|png)\b/i', $file, $matches );
And in the media_handle_sideload function, both times due to a "naked" filename.
Some popular CDN platforms are serving media files this way. (I've also seen some serve files with a query right before the extension, i.e - https://example/com/img/image?.jpg - this also fails because of the regex.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Hi there, welcome to WordPress Trac!
Thank for the report, we're already tracking this issue in #18730.