Ticket #890 (assigned enhancement)

Opened 4 years ago

Last modified 10 months ago

support relative paths for enclosures

Reported by: anonymousbugger Assigned to: markjaquith (accepted)
Priority: normal Milestone: 2.9
Component: Administration Version: 1.5
Severity: normal Keywords: has-patch 2nd-opinion
Cc:

Description

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

relative_enclosures.diff (0.6 kB) - added by markjaquith on 01/28/06 15:28:27.

Change History

02/16/05 06:15:04 changed by anonymousbugger

  • Patch set to No.

01/28/06 15:28:10 changed by markjaquith

  • keywords set to bg|has-patch.
  • owner changed from anonymous to markjaquith.
  • status changed from new to assigned.
  • milestone set to 2.1.

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).

01/28/06 15:28:27 changed by markjaquith

  • attachment relative_enclosures.diff added.

02/03/06 23:41:40 changed by moogle

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);

02/03/06 23:43:39 changed by moogle

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);

09/28/06 20:18:14 changed by foolswisdom

  • keywords changed from bg|has-patch to has-patch.

Hi Mark,

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

09/29/06 04:06:28 changed by markjaquith

  • keywords changed from has-patch to has-patch 2nd-opinion.

Lloyd,

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.

09/29/06 13:41:41 changed by zamoose

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?

09/30/06 09:38:25 changed by markjaquith

zamoose,

Only domain-relative paths are caught.

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

11/29/06 22:36:00 changed by matt

  • milestone changed from 2.1 to 2.2.

04/12/07 00:10:25 changed by rob1n

+1. Looks good.

04/12/07 18:31:01 changed by foolswisdom

  • milestone changed from 2.2 to 2.3.

09/06/07 23:36:03 changed by Nazgul

  • 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.

09/07/07 02:48:20 changed by markjaquith

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

01/24/08 18:00:52 changed by Nazgul

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

03/19/08 03:34:55 changed by ffemtcj

  • milestone changed from 2.5 to 2.6.