Make WordPress Core

Opened 10 years ago

Closed 9 years ago

#32564 closed defect (bug) (worksforme)

media_sideload_image() does not return 'src' when 'src' is passed as return parameter

Reported by: brs14ku's profile brs14ku Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.2.2
Component: Media Keywords:
Focuses: Cc:

Description

Function returns either WP_Error or the html image tag with the src in it. It doesn't return just the source when specifying it as the return parameter as the docs state here https://developer.wordpress.org/reference/functions/media_sideload_image/

Ticket #19629 is a request to add a return option of the id as an enhancement. This however, seems like a bug.

Change History (1)

#1 @dd32
9 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to worksforme
  • Status changed from new to closed

This works for me.

var_dump( media_sideload_image( 'http://example.com/test-images/dolomites.jpg', 0, '', 'src' ) );
returns: http://example.com/wp-content/uploads/2015/06/dolomites.jpg

Feel free to re-open with an example case that fails.

Note: See TracTickets for help on using tickets.