Make WordPress Core

Opened 16 years ago

Closed 11 years ago

#890 closed enhancement (wontfix)

support relative paths for enclosures

Reported by: anonymousbugger Owned by: markjaquith
Milestone: Priority: normal
Severity: normal Version: 1.5
Component: Administration Keywords: needs-patch
Focuses: Cc:


Currently, enclosures only work automatically if the URL in a post is an absolute URL. Please make them work for relative URLs as well. For example, adding a link such as <a href="/audio/mymusic.mp3"> should create an enclosure to http://www.myblog.com/audio/mymusic.mp3 and a link such as <a href="audio/mymusic.mp3"> should create an enclosure to http://www.mysite.com/blogpath/audio/mymusic.mp3">

Attachments (1)

relative_enclosures.diff (652 bytes) - added by markjaquith 15 years ago.

Download all attachments as: .zip

Change History (19)

#1 @anonymousbugger
16 years ago

  • Patch set to No

#2 @markjaquith
15 years ago

  • Keywords bg|has-patch added
  • Milestone set to 2.1
  • Owner changed from anonymous to markjaquith
  • Status changed from new to assigned

Patch fixes it. Tested. But note that your URI in the content is still going to be relative, which will break in RSS2 (but not Atom, from what I hear).

#3 @moogle
15 years ago

The relative links also need to work from within pages other than the front page (ie: archive and category pages). Wouldn't this work?:

$content = str_replace(' href="/', ' href="http://' . $_SERVERHTTP_HOST? . '/' . $_SERVERREQUEST_URI?, $content);
$content = str_replace(" href='/", " href='http://" . $_SERVERHTTP_HOST? . '/' . $_SERVERREQUEST_URI?, $content);

#4 @moogle
15 years ago

Oops, I meant:

$content = str_replace(' href="/', ' href="http://' . $_SERVERHTTP_HOST? . $_SERVERREQUEST_URI?, $content);

$content = str_replace(" href='/", " href='http://" . $_SERVERHTTP_HOST? . $_SERVERREQUEST_URI?, $content);

#5 @foolswisdom
14 years ago

  • Keywords has-patch added; bg|has-patch removed

Hi Mark,

Is this still a worthwhile enhancement? Still targeted for 2.1? Does the patch need updating?

#6 @markjaquith
14 years ago

  • Keywords 2nd-opinion added


Patch still works. Still think it's worthwhile, although it's done in such a way as to execute quickly, with a simple str_replace instead of a more complicated regex, so I'd like another pair of eyes to sign off on it.

#7 @zamoose
14 years ago

The patch looks good except for one thing: both relative and absolute server paths are caught by it and (incorrectly) routed to $SERVERHTTP_HOST?, n'est ce pas? The ticket submitter requested that both relative (audio/audio.mp3) and absolute (/audio/audio.mp3) work. Would not the current solution direct both links to http://$SERVER_URL/audio/audio.mp3, which is fine for /audio/audio.mp3 but which would be incorrect for anyone with a blog URL in any place other than the root for audio/audio.mp3. If there's no leading slash, oughtn't we just use bloginfo('url') or similar?

#8 @markjaquith
14 years ago


Only domain-relative paths are caught.

Assuming all other relative paths to be relative based on the 'home' setting might be okay. Anyone else?

#9 @matt
14 years ago

  • Milestone changed from 2.1 to 2.2

#10 @rob1n
13 years ago

+1. Looks good.

#11 @foolswisdom
13 years ago

  • Milestone changed from 2.2 to 2.3

#12 @Nazgul
13 years ago

  • Milestone changed from 2.3 to 2.4 (next)

A 3 year old enhancement ticket. I didn't even know WordPress has been around that long. :)

I'd close it as wontfix because of lack of traction, but both rob1n and markjaquith showed an interest in it, so I'll leave it up to them.

#13 @markjaquith
13 years ago

I'd still like this. :-) I'll tackle it for 2.4

#14 @Nazgul
13 years ago

Mark, you missed 2.4. Retry for 2.5? ;)

#15 @ffemtcj
13 years ago

  • Milestone changed from 2.5 to 2.6

#16 @Denis-de-Bernardy
11 years ago

+1 to wontfix

#17 @Denis-de-Bernardy
11 years ago

  • Keywords needs-patch added; has-patch 2nd-opinion removed

#18 @ryan
11 years ago

  • Milestone 2.9 deleted
  • Resolution set to wontfix
  • Status changed from accepted to closed
Note: See TracTickets for help on using tickets.