Make WordPress Core

Opened 10 years ago

Last modified 10 months ago

#1914 reopened enhancement

Permalinks for unattached uploads/attachments

Reported by: dlhau@… Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version: 1.6
Component: Permalinks Keywords: dev-feedback has-patch needs-testing
Focuses: Cc:


Currently attachement links are in the form:


Would look much neater if these matched the permalinks of regular posts (depending on what it is configured to) eg:


Attachments (2)

attachment-permalinks.diff (3.2 KB) - added by MikeNGarrett 2 years ago.
Attachment Permalinks diff
1914.diff (475 bytes) - added by SergeyBiryukov 12 months ago.

Download all attachments as: .zip

Change History (16)

comment:1 @skeltoac10 years ago

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

Attachment permalinks are in the form [parent permalink]/[attachment slug]. There is not an intermediate attachment permalink style. What is an attachment without something to attach to?

It has not been decided what to do with orphaned attachments, although I think we should drop and unlink.

comment:2 @anonymous9 years ago

  • Milestone 2.0 deleted

Milestone 2.0 deleted

comment:3 @Viper007Bond4 years ago

  • Component changed from Administration to Permalinks
  • Keywords needs-patch added
  • Milestone set to Future Release
  • Resolution wontfix deleted
  • Status changed from closed to reopened
  • Summary changed from Attachement Permalinks to Permalinks for unattached uploads/attachments
  • Type changed from defect (bug) to enhancement

Re-opening this guy.

If media is uploaded using Media -> Add New, it doesn't get a permalink because it doesn't have a post.

I'd like to suggest the idea proposed in the original post be reconsidered. Query strings are ugly. :)

Last edited 4 years ago by Viper007Bond (previous) (diff)

comment:4 @johnbillion4 years ago

  • Cc johnbillion@… added

comment:5 @Hekos4 years ago

  • Cc marko@… added

comment:6 @dd323 years ago

Currently http://example.com/attachment-slug-name/ will work for Attachments not attached to any posts, but we don't generate links using that format.

@MikeNGarrett2 years ago

Attachment Permalinks diff

comment:7 @MikeNGarrett2 years ago

Attached a patch here to enable this functionality. I'd love to get this request closed up since it's the oldest ticket in trac.

comment:8 @SergeyBiryukov12 months ago

#29426 was marked as a duplicate.

comment:9 follow-up: @keketovic12 months ago

  • Keywords 2nd-opinion dev-feedback added

Rather shame to see this as "won't fix". It just shows your general attitude to understanding of what permanent (and pretty) URLs should look like for the whole Wordpress, not just part of it, because some of the attachments are "orphans".

BTW, as a temporary fix I have reattached these orphans to the parent posts, so Wordpress now actually works instead of showing ugly URLs.

If prepending general "attachment/" part is not the solution to this and you don't offer any other suggestions than nothing is. I find the developers in this thread somehow pathetic in their stance towards this simple (and moreover logical - permalinks structure is set up after all!) request.

BTW, easy patch to fix this was uploaded exactly 12 months ago and nobody paid attention. That says something, doesn't it?

comment:10 @SergeyBiryukov12 months ago

Per comment:8, we should probably just leverage the existing format in get_attachment_link() instead of introducing new rewrite rules.

comment:11 in reply to: ↑ 9 @helen12 months ago

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

Replying to keketovic:

Rather shame to see this as "won't fix".

I find the developers in this thread somehow pathetic in their stance towards this simple (and moreover logical - permalinks structure is set up after all!) request.

This ticket is open. A lot of things change in 9 years. Let's all stay away from attacks, please.

We de-emphasize the attachment relationship in some ways now. I would agree that this is worth revisiting in that light. "Attachment" doesn't really seem like the right way to refer to a media item when it's not attached, though. We don't call it the "Attachment Library".

@SergeyBiryukov12 months ago

comment:13 @Drivingralle10 months ago

I applied the two patches.
For the obvious case to query a single attachment page it works fine.

Are there special cases that I can test?

comment:14 in reply to: ↑ 12 @MikeNGarrett10 months ago

  • Keywords needs-testing added

Replying to SergeyBiryukov:

1914.diff implements comment:10.

I tested all the changes from this patch (not including my patch for added rewrite rules) and it looks good.
I tested a number of different permalink settings. I think this is ready to go.

Note: See TracTickets for help on using tickets.