Make WordPress Core

Opened 6 years ago

Last modified 4 years ago

#32999 new enhancement

Provide a way to not attached unattached image when inserting into post.

Reported by: husobj Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 4.2.2
Component: Media Keywords:
Focuses: Cc:


Back around WordPress 3.5 the functionality was introduced to attach unattached images to a post when they are inserted into editor #22085


This may not always be desired behaviour.

I have used (and created) themes that automatically display galleries based on images attached to a post. If I then want to insert another image from the media library into the post editor such as a logo, this image then becomes attached and automatically becomes part of the auto-generated gallery.

Similarly there are cases where you may automatically want to select an attached image to use as a featured image if no featured image is set. For example eCommerce products where removing the requirement to set a featured image is implemented. In this case you would also want to insert other images into the editor without them attaching.

In the case of an image like a logo, this is a generic image in my media library that may get used by many posts and I would not necessarily want it to become associated with a specific post. Automatically creating that relationship may be confusing.

So my question is would it be possible to introduce a filter so that this default behaviour can be prevented?

It would also relate to #23041 (attaching unattached images when inserting gallery) as you would want the filter to prevent this too.

Change History (2)

#1 @husobj
6 years ago

See this post by Herb Miller:

Provides a way to do this via a action by overriding the $_POST['post_id']

It works but is not ideal as the originally post ID won't be available for later actions if required.

This ticket was mentioned in Slack in #core-media by desrosj. View the logs.

4 years ago

Note: See TracTickets for help on using tickets.