WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#27222 closed defect (bug) (fixed)

get_uploaded_header_images() returns the incorrect image URL

Reported by: Kopepasah Owned by: johnbillion
Milestone: 3.9 Priority: normal
Severity: normal Version: 3.2
Component: Customize Keywords: has-patch dev-feedback commit
Focuses: Cc:

Description

When using a CDN (e.g. S3 ) and a plugin that modifies the File URL for an attachment (e.g. Amazon S3 and CloudFront), the get_uploaded_header_images() function returns an array with the unmodified URL instead of the new URL.

In the case of this particular plugin, we have the option of removing the media from the media folder and using the media strictly on the CDN; however, the result is a blank image (by looking in the empty media library) instead of the image on the CDN.

The attached patch uses wp_get_attachment_url( $header->ID ) in lieu of $header->guid to return the correct URL.

Attachments (1)

27222.patch (510 bytes) - added by Kopepasah 3 years ago.

Download all attachments as: .zip

Change History (7)

@Kopepasah
3 years ago

#1 @Kopepasah
3 years ago

  • Keywords has-patch dev-feedback added

#2 @SergeyBiryukov
3 years ago

  • Keywords commit added
  • Milestone changed from Awaiting Review to 3.9
  • Version changed from trunk to 3.2

Introduced in [17757].

This ticket was mentioned in IRC in #wordpress-dev by nacin. View the logs.


3 years ago

#4 @kovshenin
3 years ago

I can't really think of anything that can go wrong with 27222.patch and it kinda makes sense.

A workaround could be changing the guid during attachment insert, especially if the original file is not saved locally, in which case you'll end up with a guid pointing to a file that does not exist, regardless of what wp_get_attachment_url() or get_uploaded_header_images() return.

#5 @johnbillion
3 years ago

  • Owner set to johnbillion
  • Resolution set to fixed
  • Status changed from new to closed

In 27434:

Use wp_get_attachment_url() instead of the GUID when getting header image URLs. Fixes #27222. Props Kopepasah.

#6 @SergeyBiryukov
3 years ago

#22986 was marked as a duplicate.

Note: See TracTickets for help on using tickets.