Make WordPress Core

Opened 13 years ago

Last modified 4 years ago

#18730 new defect (bug)

media_sideload_image() doesn't handle dynamic image url's well

Reported by: dd32's profile dd32 Owned by:
Milestone: Priority: normal
Severity: normal Version: 2.9
Component: Media Keywords: has-patch needs-refresh
Focuses: Cc:


Example URL:

As a result, the preg_match() for the file extension fails and issues a notice (no file extension in that url, although the redirection location does have).

The handling of a download failure also seems hairy, upon failure, it still attempts further importing before loading - I haven't looked into that too far.

Attachments (1)

18730.patch (1.4 KB) - added by kurtpayne 13 years ago.
Determine file extension based on content type header

Download all attachments as: .zip

Change History (9)

#1 @JustinSainton
13 years ago

  • Cc JustinSainton added

Probably not relevant for your use case, and I'm sure you're very well aware of the filter, but I was able to get around a similar bug by modifying the wp_check_filetype_and_ext filter as such -

add_filter( 'wp_check_filetype_and_ext', 'gd_pdf_bypass' );

function gd_pdf_bypass( $filearray ) {
    $filearray['type'] = 'image/jpeg';
    $filearray['ext'] = 1;
    return $filearray;

Granted, still doesn't attach properly (not necessary in my use case), but I'm able to get it to return the proper <img> tag and upload to the server with the override.

Last edited 13 years ago by JustinSainton (previous) (diff)

13 years ago

Determine file extension based on content type header

#2 @kurtpayne
13 years ago

  • Cc kpayne@… added
  • Keywords has-patch added
  • Version set to 2.9

#3 @c3mdigital
12 years ago

  • Cc chris@… added

I'm having this issue with some of my users in my media-tools plugin which imports and attaches external images. I'm going to work on refreshing the patch for 3.5.

#4 @nacin
10 years ago

  • Component changed from Warnings/Notices to Media

#5 @wonderboymusic
10 years ago

  • Milestone changed from Awaiting Review to Future Release

#6 @chriscct7
9 years ago

  • Keywords needs-refresh added

#7 @SergeyBiryukov
4 years ago

#49944 was marked as a duplicate.

This ticket was mentioned in Slack in #core by arunas. View the logs.

4 years ago

Note: See TracTickets for help on using tickets.