Opened 16 years ago
Closed 16 years ago
#7622 closed defect (bug) (fixed)
wp_get_attachment_url() uses the GUID as the URL
Reported by: | DD32 | Owned by: | |
---|---|---|---|
Milestone: | 2.7 | Priority: | normal |
Severity: | normal | Version: | 2.7 |
Component: | Template | Keywords: | has-patch blessed |
Focuses: | Cc: |
Description
At present wp_get_attachment_url() relies upon the GUID for the URL of the attachment, As discussed on wp-hackers ("Re: [wp-hackers] Re: permalinks redirected despite WP_SITEURL") this shouldnt be done due to the fact that it just so happens that the guid is the url in wordpress
The attached patch attempts to use the attachment metadata to workout the files location, followed by using the filtered uploads directory to determine the real location (See comments in patch).
Attachments (4)
Change History (12)
#3
@
16 years ago
I expanded the patch so that files are saved to attachment meta data with paths relative to upload dir rather than absolute paths. That makes it much easier to change your content dir location or move your blog to another host.
Note: See
TracTickets for help on using
tickets.
A possibly better option would be to use _wp_attached_file metadata, see the attached patch.
Also note, That in the event the metadata fails, the uploads folder is not located, or the file does not exist within the uploads folder, it fails back to using the GUID