WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 7 months ago

#32999 closed enhancement (wontfix)

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

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

Description

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

wp_ajax_send_attachment_to_editor()
https://core.trac.wordpress.org/browser/trunk/src/wp-admin/includes/ajax-actions.php#L2465

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 (3)

#1 @husobj
6 years ago

See this post by Herb Miller:
http://herbmiller.me/2015/07/15/h2gd-part-45-how-to-remain-detached/

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

#3 @desrosj
7 months ago

  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from new to closed

Hi @husobj,

First, my apologies that this didn't receive a response in a timely manner!

A lot has changed since this issue was created, and the Classic Editor (which uses wp_ajax_send_attachment_to_editor()) is now in maintenance mode only. The block editor uses the REST API to perform actions like this instead, and does so through JavaScript packages developed in the Gutenberg repository over on GitHub.

If this is still something you're interested in, please head over there and create an issue so it can be looked into.

Note: See TracTickets for help on using tickets.