Make WordPress Core

Opened 12 months ago

Last modified 3 months ago

#46113 new defect (bug)

Incongruent returned value for wp_get_attachment_image_src

Reported by: wido Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version: 2.5
Component: Media Keywords: needs-patch
Focuses: docs Cc:
PR Number:


As per docblock the function wp_get_attachment_image_src will return false|array Returns an array (url, width, height, is_intermediate), or false, if no image is available.

Function wp_get_attachment_image_src return an indexed array containing source, width and height, but not the intermediated value in case the internal call to image_downsize return false.

It's this latter that will return the array containing all of the elements, therefore if it's false wp_get_attachment_image_src will try to create them but will miss is_intermediated value.

Change History (4)

#1 @desrosj
12 months ago

  • Focuses docs added

#2 @joemcgill
9 months ago

  • Milestone changed from Awaiting Review to Future Release

Good catch, @wido. The docs should be updated here to note that the fourth value in the array, i.e. is_intermediate is optional.

#3 @wido
3 months ago

@joemcgill What adding a default value for it instead? This will make the function more predictable.
False would be a good choice, it's the same default in image_downsize

#4 @joemcgill
3 months ago

@wido I think that would work too.

Note: See TracTickets for help on using tickets.