WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.55k stars 4.22k forks source link

Image Block: When adding an existing image within a post, explore "attaching" the image to the post if it isn't already attached #66663

Open andrewserong opened 3 weeks ago

andrewserong commented 3 weeks ago

What problem does this address?

Follows #12753

This issue was raised as part of a much earlier issue (#12753) in this comment: https://github.com/WordPress/gutenberg/issues/12753#issuecomment-556149071

Worth noting here that some work would need to be done to ensure Gutenberg added images are properly seen as attached. Right now, you can have an image in a Gutenberg post or page but the status in WP Admin > Media will still show unattached.

In Gutenberg, if we upload an image to a particular post, then the uploaded image will be "attached" to that post. I.e. if you go to the media library, you can see that it's attached to the post:

Image

However, if we simply select an image from the media library and add it to a post or page, it does not "attach" it to the post.

To verify, add some images to a site via the media library. Then, go to create a post or page. Add the image to the post or page and publish. Then, go to the media library, and the image will still say Unattached under the Uploaded to column:

Image

What is your proposed solution?

When a user adds an image from the media library to a post or page, if the image is not already attached to any post (is unattached), then attach the image to the post.

That's the proposal here! Does this sound good, or are there any potential gotchas, concerns, issues that could arise by introducing this?

Marc-pi commented 3 weeks ago

yep, i stumbled upon this case this week on a customer website, deleting some media flagged as unattached, but were not ;-)

Mamaduka commented 1 day ago

Somewhat related to the Media Library behavior - #17658.