WordPress.org

Make WordPress Core

Opened 7 years ago

Closed 4 years ago

#27983 closed defect (bug) (invalid)

Attachment "Uploaded to" field doesn't change after removing it from post content

Reported by: tedinoz Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.8.1
Component: Media Keywords:
Focuses: Cc:

Description

If an image is inserted in a post, the Media Library displays the post name with a hyperlink to the post-edit page. However, if the image is later deleted from the post, the "updated to" field continues to display the details of the post.

This not a "new" issue. I have reproduced it in both WP3.9 and WP3.8.1
I think it has been around for a while.

How to reproduce the bug:

1 = Open Media Library, upload a new image ("Image A"). Note that the Media Library shows that the image is not "Uploaded to" to any post.

2 = Open an existing post (it doesn't matter whether or not the post has attached images), click the "Add Media" button and insert "Image A". Save the post, view the post and note that image appears in the post.

3= Open the Media Library and note that "Image A" is shown as "Updated to" your post.

4 = Re-open your post, click on the image, and click the "Delete Image" icon. The image is deleted from the edit post screen. Save the post, view the post and note that image does not appear in the post.

5 = Logout of WordPress, clear your cache, and login again (this step is intended to demonstrate that this is not a session-based issue).

6 = Open the Media Library and locate "Image A". The "Uploaded to" column shows the name of your post despite that you deleted the image from the post.

Change History (15)

#1 @tedinoz
7 years ago

Just ran this with latest WP3.9, clean install, no plugins. Bug exists as described above.

#2 @bilalcoder
7 years ago

looks like the 'insert button' in media popup updates the attachment related post, if you insert any image to the editor without updating the post it'll become attached.

#3 @tedinoz
7 years ago

+1 to bilalcoder

Note: bilalcoder's comments are in addition to the "Delete Image" original bug.

I guess one might say that the whole process of "attaching" and "unattaching" is fatally flawed.

#4 @klihelp
7 years ago

same here, wanted to report this too.

#5 @ericlewis
6 years ago

  • Keywords needs-patch added

#6 @ericlewis
6 years ago

  • Summary changed from Media Library screen not updated when Image is deleted from Post to Attachment "Uploaded to" field doesn't change after removing it from post content

#7 follow-up: @SergeyBiryukov
6 years ago

  • Keywords reporter-feedback 2nd-opinion added; needs-patch removed

An image attached to a post does not necessarily have to be present in its content.

I don't see an issue here. What's wrong with keeping an image attached to a post after it's been removed from content? You can still use it in other posts and galleries.

See #6820 for the ability to reattach an image to another post. There's also a plugin for that.

#8 in reply to: ↑ 7 @tedinoz
6 years ago

  • Keywords needs-patch added

SergeyBiryukov, you ask "What's wrong with keeping an image attached to a post after it's been removed from content? You can still use it in other posts and galleries." With the greatest respect, you have both missed the point and trivialised the issue.

We have an obligation is to ensure that the information managed and displayed by WordPress is accurate and reliable. The Media Library represents to disclose details of the post to which an image is "updated to" however, in the case of images removed from posts, this is information is not accurate. In short, that is "what's wrong" - the information displayed in the Media Library is inaccurate and unreliable.

Moreover, you appear to suggest that a database entry linking an image to a post should not be modified to record that the image has been removed from the post. This would seem to suggest that you are in favour of retaining inaccurate information in the database.

In the context of this Trac request, there are 3 scenarios that can lead to inaccurate information.
1 = Image X has never been assigned to a post. A post is open for edit and Image X is added to the post but the post is NOT saved/updated; the Media Library shows that Image X is "Updated to" the post.

2 = Image Y has never been assigned to a post. A post is open for edit and Image Y is added to the post, the post is saved/updated; the Media Library shows that Image Y is "Updated to" the post. At a later date the post is edited and Image Y is removed from the post; the Media Library shows that Image Y is (still) "Updated to" the post.

3 = Image Y is subsequently attached to several posts yet the Media Library shows that Image Y is (still) "Updated to" the original post and makes no mention of other posts to which it is attached.

I suggest that your 2nd opinion is wrong and should be removed. The need for a solution to the Trac request (whether it be a patch or not) should be confirmed.

#9 @wonderboymusic
6 years ago

  • Keywords reporter-feedback 2nd-opinion needs-patch removed
  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from new to closed

"Uploaded to" just means that you had the post open when you uploaded the image - it describes original intent. Nothing "breaks" because of it.

The editor takes freeform content. The engine does not parse your content looking for what you might have to done to freeform HTML that was inserted into the post when updating.

The main reason we cannot break the relationship of "Uploaded to" is simple: [gallery] can exist with no attributes, and will pull the images "Uploaded to" the post. Same is true for [playlist].

If that relationship is broken because they aren't in the post on save, this would break many existing posts that relied on [gallery].

#10 follow-up: @bravadomizzou
6 years ago

  • Resolution wontfix deleted
  • Status changed from closed to reopened

Calling get_attached_media() will show that said file is attached to it. This does not make sense to me. At the very least if this method can't be updated, add a section in the popup (when clicking "add media" on a post) that shows media attached to this post, and allow user to detach the file.

#11 in reply to: ↑ 10 @SergeyBiryukov
6 years ago

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

Replying to bravadomizzou:

At the very least if this method can't be updated, add a section in the popup (when clicking "add media" on a post) that shows media attached to this post, and allow user to detach the file.

See #6820 for the ability to detach or reattach files. There's also a plugin for that.

#12 @tedinoz
6 years ago

  • Resolution wontfix deleted
  • Status changed from closed to reopened

Thanks for clarifying that the "Uploaded to" column doesn't reflect the current status; rather it is just the "original intent".

So then, why display the "Uploaded to" column at all?

#13 @SergeyBiryukov
6 years ago

  • Milestone set to Awaiting Review

#14 @SergeyBiryukov
5 years ago

#34469 was marked as a duplicate.

#15 @SergeyBiryukov
4 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from reopened to closed

No traction here, and the current functionality works as intended, per comment:9.

Removing the "Attached to" column was previously discussed in #22439, and it was renamed to "Uploaded to" instead. If the suggestion is to reconsider that, a new ticket should be opened.

Note: See TracTickets for help on using tickets.