Make WordPress Core

Opened 19 years ago

Closed 9 years ago

#1914 closed enhancement (fixed)

Permalinks for unattached uploads/attachments

Reported by: dlhaudeakineduau's profile dlhau@… Owned by: pento's profile pento
Milestone: 4.4 Priority: normal
Severity: normal Version: 1.6
Component: Permalinks Keywords: has-patch needs-unit-tests
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 (4)

attachment-permalinks.diff (3.2 KB) - added by MikeNGarrett 11 years ago.
Attachment Permalinks diff
1914.diff (475 bytes) - added by SergeyBiryukov 10 years ago.
1914.2.diff (1.9 KB) - added by wonderboymusic 9 years ago.
1914.3.diff (2.6 KB) - added by wonderboymusic 9 years ago.

Download all attachments as: .zip

Change History (27)

#1 @skeltoac
19 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.

#2 @(none)
18 years ago

  • Milestone 2.0 deleted

Milestone 2.0 deleted

#3 @Viper007Bond
13 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 13 years ago by Viper007Bond (previous) (diff)

#4 @johnbillion
13 years ago

  • Cc johnbillion@… added

#5 @Hekos
13 years ago

  • Cc marko@… added

#6 @dd32
12 years ago

Currently will work for Attachments not attached to any posts, but we don't generate links using that format.

11 years ago

Attachment Permalinks diff

#7 @MikeNGarrett
11 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.

#8 @SergeyBiryukov
10 years ago

#29426 was marked as a duplicate.

#9 follow-up: @keketovic
10 years 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?

#10 @SergeyBiryukov
10 years ago

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

#11 in reply to: ↑ 9 @helen
10 years 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".

10 years ago

#13 @Drivingralle
10 years 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?

#14 in reply to: ↑ 12 @MikeNGarrett
10 years 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.

#15 @SergeyBiryukov
9 years ago

#33664 was marked as a duplicate.

#16 @SergeyBiryukov
9 years ago

  • Keywords needs-unit-tests added; dev-feedback needs-testing removed
  • Milestone changed from Future Release to 4.4

#17 @swissspidy
9 years ago

  • Keywords needs-refresh added

1914.diff only solves half of the problems:

  • The ugly permalink is still shown at some places, like in the media list table and when editing the media item
  • Doesn't work in every scenario. For example, when a media item is attached to some post that is from an old post type (not registered anymore, just lying in the database), the ugly permalink is used. There's no redirect to the pretty permalink.

#18 @wonderboymusic
9 years ago

  • Keywords needs-refresh removed

1914.2.diff accomplishes the goals of comment:17

#19 @wonderboymusic
9 years ago

1914.3.diff resets some flags after posts are queried to break the collision with pages, makes unit tests pass

#20 @wonderboymusic
9 years ago

  • Owner set to SergeyBiryukov
  • Status changed from reopened to assigned

#21 @wonderboymusic
9 years ago

  • Owner changed from SergeyBiryukov to pento

This ticket was mentioned in Slack in #core by wonderboymusic. View the logs.

9 years ago

#23 @pento
9 years ago

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

In 34690:

Permalinks: Add pretty permalinks for unattached attachments.

Previously, unattached attachments would have unsightly /?attachment_id=1 URLs. As we've moved away from attachments being specifically attached to posts, instead being Media items, this has made the unattached URLs a more common occurrence.

We can breath easy once more, knowing that the world is a little bit safer from the horror of unnecessarily ugly URLs.

Props SergeyBiryukov, wonderboymusic, pento.

Fixes #1914.

Note: See TracTickets for help on using tickets.