WordPress.org

Make WordPress Core

Opened 7 years ago

Closed 2 months ago

Last modified 5 weeks ago

#6820 closed enhancement (fixed)

Make it possible to manually detach/attach post images

Reported by: matt Owned by: matt
Milestone: 4.2 Priority: low
Severity: minor Version:
Component: Media Keywords: has-patch dev-feedback 4.2-beta
Focuses: ui Cc:

Description

You should be able to change the parent of an attachment to attach it to a different post.

Attachments (9)

detach_media.diff (5.8 KB) - added by dphiffer 4 years ago.
AJAX-style media detaching with bulk option
detach_media2.diff (6.6 KB) - added by dphiffer 4 years ago.
Updated after getting some feedback from nacin
6820.diff (6.3 KB) - added by wonderboymusic 5 months ago.
6820.2.diff (5.1 KB) - added by wonderboymusic 5 months ago.
6820.3.diff (9.9 KB) - added by wonderboymusic 3 months ago.
6820.4.diff (9.4 KB) - added by wonderboymusic 3 months ago.
6820.5.diff (9.5 KB) - added by wonderboymusic 3 months ago.
Screen Shot 2015-03-05 at 8.24.26 AM.png (667.0 KB) - added by ryan 3 months ago.
IMG_3310.PNG (143.2 KB) - added by ryan 3 months ago.
iPhone 5 screenshot, for the record. The "Uploaded to" column doesn't show on mobile.

Download all attachments as: .zip

Change History (56)

comment:1 @DD326 years ago

  • Component changed from Administration to Gallery
  • Keywords needs-patch added

comment:2 @Denis-de-Bernardy6 years ago

  • Keywords 2nd-opinion added
  • Priority changed from normal to low
  • Severity changed from normal to minor

Isn't this done automatically when an attachment has no parent?

Also, wouldn't it be more reliable to duplicate the attachment, with a new parent, when it gets inserted in a separate post?

comment:5 @Denis-de-Bernardy6 years ago

  • Keywords blessed 2nd-opinion removed

comment:6 @ryan6 years ago

  • Milestone changed from 2.9 to Future Release

comment:7 @dphiffer4 years ago

  • Keywords has-patch needs-testing added; needs-patch removed

comment:8 @dphiffer4 years ago

  • Cc dan@… added

@dphiffer4 years ago

AJAX-style media detaching with bulk option

comment:9 @scribu4 years ago

  • Cc scribu added

@dphiffer4 years ago

Updated after getting some feedback from nacin

comment:10 @WraithKenny4 years ago

  • Cc Ken@… added

comment:11 @TomAuger4 years ago

  • Cc TomAuger added

comment:12 @lkraav3 years ago

  • Cc lkraav added

comment:13 @sabreuse3 years ago

  • Cc sabreuse@… added

comment:14 @aaroncampbell3 years ago

  • Cc aaroncampbell added

comment:15 @SergeyBiryukov3 years ago

Closed #14042 and #15557 as a duplicates.

Version 1, edited 3 years ago by SergeyBiryukov (previous) (next) (diff)

comment:16 @Mamaduka3 years ago

  • Cc georgemamadashvili@… added

comment:17 @ruud@…3 years ago

  • Cc ruud@… added

comment:18 @knutsp3 years ago

  • Cc knut@… added

comment:19 @SergeyBiryukov2 years ago

#22675 was marked as a duplicate.

comment:20 @DrewAPicture7 months ago

  • Summary changed from Post image / attachment reparenting to Make it possible to manually detach/attach post images

comment:21 @DrewAPicture7 months ago

  • Component changed from Gallery to Media
  • Focuses ui added

comment:22 @DrewAPicture7 months ago

#14042 was marked as a duplicate.

@wonderboymusic5 months ago

comment:23 @wonderboymusic5 months ago

  • Keywords needs-testing removed
  • Milestone changed from Future Release to 4.2

6820.diff Adds a Detach link for Media Grid attachment details modal and for list table rows. Haven't done bulk yet

@wonderboymusic5 months ago

comment:24 @DrewAPicture3 months ago

  • Keywords needs-refresh added

6820.2.diff needs a refresh, and it sounds like a treatment for bulk actions per comment:23. Screenshots would be nice too.

@wonderboymusic3 months ago

@wonderboymusic3 months ago

@wonderboymusic3 months ago

comment:25 @wonderboymusic3 months ago

In 31619:

Allow attachments to be Detached from their parent in media grid and list modes.

See #6820.

comment:26 @DrewAPicture3 months ago

  • Keywords needs-docs added; needs-refresh removed

wp_media_attach_action() parameter docs are incomplete.

comment:27 @ryan3 months ago

Looking forward to the day when users don't ever see the terms attach or detach. This whole thing is a hack around the lack of API for getting images from content.

comment:28 @wonderboymusic3 months ago

In 31624:

detached affects the wp() call for the media list table, so switch our new $_GET key to detach.

See #6820.

@ryan3 months ago

iPhone 5 screenshot, for the record. The "Uploaded to" column doesn't show on mobile.

comment:29 follow-up: @DrewAPicture3 months ago

  • Keywords dev-feedback 4.2-beta added

@ryan: What would be your recommendation on the "Uploaded To" column on mobile? Should it actually show? Seems like adding a fourth column would make that even more unnecessarily scrunched.

comment:30 @Stagger Lee3 months ago

Would it be helpful to show them on very small devices like this ?

  • Image bigger and centered above.
  • Other columns as display:block beneath centered image.

Scrolling with Smartphones goes very fast and easy, so height would not make such difference and problems.

Problem is header would be repeated for each item. If this could be solved in some way. Image doesnt need header title, it is self explanatory.

Last edited 3 months ago by Stagger Lee (previous) (diff)

comment:31 in reply to: ↑ 29 ; follow-up: @ryan3 months ago

Replying to DrewAPicture:

@ryan: What would be your recommendation on the "Uploaded To" column on mobile? Should it actually show? Seems like adding a fourth column would make that even more unnecessarily scrunched.

I think list tables on mobile should be one column. We should decide what needs to be exposed on mobile and make some editorial decisions. Related: #29993. And #29991, #29992, #29994, #29995.

Failing that, I'd leave Uploaded To hidden and keep attach/detach off of mobile. The attach modal likely needs work on mobile, and since detach has no confirmation I will almost certainly accidentally tap it while scrolling.

Someday, let's discuss how to kill the notion of attached and detached. I end up with unattached images all the time because I often share straight to the media lib from mobile and later blog from desktop (making galleries on mobile is difficult). Images uploaded to the media lib don't get attached to posts when they are later published. This messes up filtering down to images uploaded to the post and messes up reader plugins (which are still reliant on attached status and featured images and don't have API for getting all images in content). Instead of making users manually attach images, we should pursue attachment independence further. Galleries no longer depend on attached status. Let's finish the job.

Last edited 3 months ago by ryan (previous) (diff)

comment:32 @knutsp3 months ago

Also related: #30691

comment:33 in reply to: ↑ 31 @helen3 months ago

Replying to ryan:

since detach has no confirmation

We should probably do something about that in the meantime.

comment:34 @slackbot3 months ago

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

comment:35 follow-ups: @melchoyce3 months ago

Someday, let's discuss how to kill the notion of attached and detached. I end up with unattached images all the time because I often share straight to the media lib from mobile and later blog from desktop (making galleries on mobile is difficult). Images uploaded to the media lib don't get attached to posts when they are later published. This messes up filtering down to images uploaded to the post and messes up reader plugins (which are still reliant on attached status and featured images and don't have API for getting all images in content). Instead of making users manually attach images, we should pursue attachment independence further. Galleries no longer depend on attached status. Let's finish the job.

I admit that when I saw this ticket pop up, that was my first thought — why do we even have attached/detached? I'm honestly barely even sure I understand what it really means. Is it still used for anything? I'm sure the vast majority of users don't know and don't care — they just want to add and remove images from their post content. Attach/detach feels like an irrelevant concept in today's WordPress.

comment:36 in reply to: ↑ 35 @aaroncampbell3 months ago

Replying to melchoyce:

I admit that when I saw this ticket pop up, that was my first thought — why do we even have attached/detached? I'm honestly barely even sure I understand what it really means. Is it still used for anything? I'm sure the vast majority of users don't know and don't care — they just want to add and remove images from their post content. Attach/detach feels like an irrelevant concept in today's WordPress.

I agree, as far as core, but I think it's likely that numerous plugins leverage these relations quite a bit. The real problem, in my opinion, isn't the idea that media can be attached to a post, it's that it can only be attached to a single post (it uses post parent). It really becomes the classic post-to-post relation issue though, which we don't solve for other post types, so maybe we shouldn't try to solve it for media either?

comment:37 in reply to: ↑ 35 ; follow-up: @afercia3 months ago

Replying to melchoyce:

why do we even have attached/detached? I'm honestly barely even sure I understand what it really means. Is it still used for anything? I'm sure the vast majority of users don't know and don't care

That comes from a developer's point of view, giving how attached media are stored in the DB and then fetched, especially how media meta data are fetched. Of course this doesn't make any sense from a user's perspective, as you pointed out, users just want to add and remove images.
Maybe time to consider a DB schema upgrade? After all, media inside a post are content and maybe media IDs should be stored in the post itself.

comment:38 in reply to: ↑ 37 ; follow-up: @helen2 months ago

Replying to afercia:

Maybe time to consider a DB schema upgrade?

Congratulations, you have arrived at #14513. You should now consider yourself a seasoned WordPress core contributor (if you don't already). :)

I am actually rather inclined to revert this and leave it to existing plugins. If somebody's site relies on attach/detach functionality today, that is completely understandable, but I don't think we should go back to emphasizing these under-the-hood concepts by default.

comment:39 @helen2 months ago

I should note that it may be okay to leave in the list table (adding an AYS), though, since it has the column and attachment modal and I don't see us killing that off since it's almost like a legacy mode right now. The Backbone-ified version doesn't show anything if it's not attached to something, though, so I'd rather not start showing "Detach" there.

comment:40 @slackbot2 months ago

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

comment:41 @husobj2 months ago

I have used (and created) many plugins that rely on the attachment -> post as parent relationship so until such time as #14513 becomes a possibility I think we have to keep this functionality.

However, I would agree with @helen that we don't need to "emphasise these under-the-hood concepts" by default.
There are quite a few plugins that add attach/detach functionality and UI, and I'm not sure that this needs to be added to core until the future of a post relationship schema is more certain?

comment:42 in reply to: ↑ 38 @DrewAPicture2 months ago

Replying to helen:

I am actually rather inclined to revert this and leave it to existing plugins. If somebody's site relies on attach/detach functionality today, that is completely understandable, but I don't think we should go back to emphasizing these under-the-hood concepts by default.

I agree that a revert is the best option at this stage.

comment:43 @DrewAPicture2 months ago

  • Keywords needs-docs removed

comment:44 @wonderboymusic2 months ago

I semi-agree with the JS parts, but not with reverting "detach" in general. I agree Attach/Detach is lame, but if you are going to have Attach in the list table, there should be Detach.

When you upload an image using the media modal on the Post screen, and then decide to not use that image in the post, you are still stuck with this relationship which affects the attachment forever. Namely, its URL.

http://woo.com/2015/03/17/drew-jaynes/unrelated-media-that-i-didnt-attach/

Having the Detach link allows the Drew Jaynes related portion the URL to go in the dumpster, and this strange post relationship to disappear. If indeed you are using something like [gallery], you might expect these URLs to operate this way.

comment:45 @slackbot2 months ago

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

comment:46 @wonderboymusic2 months ago

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

In 31960:

Remove the JS part of [31619].

Fixes #6820.

comment:47 @nacin5 weeks ago

I'll point out that leaving this in for 4.2, does not, in my opinion, prevent us from completely removing *both* Attach and Detach in the future. I agree with having it for now, but eventually it'd be nice to have the option to sandbag it.

Note: See TracTickets for help on using tickets.