Make WordPress Core

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's profile 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)

7622.diff (1.1 KB) - added by DD32 16 years ago.
7622.2.diff (1.1 KB) - added by DD32 16 years ago.
7622.3.diff (2.9 KB) - added by ryan 16 years ago.
Make attachment file path relative to the upload dir
7622.patch (1.6 KB) - added by DD32 16 years ago.

Download all attachments as: .zip

Change History (12)

@DD32
16 years ago

#1 @DD32
16 years ago

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

@DD32
16 years ago

#2 @ryan
16 years ago

  • Keywords blessed added

Definitely needs to be done. I'll try it out.

@ryan
16 years ago

Make attachment file path relative to the upload dir

#3 @ryan
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.

#4 @ryan
16 years ago

(In [8796]) Make attachment file path relative to the upload dir. Don't use GUID to find attachement URL. Props DD32. see #7622

#5 @DD32
16 years ago

Changeset broke image thumbnail creation. (The full path is not passed to the image creation functions)

attached patch fixes it.

@DD32
16 years ago

#6 @DD32
16 years ago

Looks like it also broke the exif retrieval, Patch refreshed with extra change.

#7 @ryan
16 years ago

(In [8879]) Thumbnail and exif fixes from DD32. see #7622

#8 @DD32
16 years ago

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

WP no longer relies on the GUID for the attachment url (but falls back to it), And it seems like the bugs caused by it have been fixed up, So closing as fixed.

Note: See TracTickets for help on using tickets.