Make WordPress Core

Opened 13 years ago

Closed 13 years ago

#13790 closed enhancement (duplicate)

Media Uploader's "Insert into Post" button disappears when editor is removed from custom post type - requesting addition of filter to override this behavior

Reported by: goto10's profile goto10 Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Media Keywords:
Focuses: Cc:

Description

I'm launching the Media Uploader from a button a la: here However, since my post type does not support the editor, the Insert into Post button does not appear.

Sivel explained to me that this is intended behavior, but the addition of a new filter would make things cleaner for "strange" post types like the one I'm trying to create. For now, I have worked around the issue by hiding the editor with css.

Here is a chat log where sivel brainstormed a possible solution:

<goto10> Hey guys (I was just directed here from #wordpress).  I think I may have found a bug in 3.0rc1:
	I'm using a custom post type with meta boxes.  One of the fields within a meta box is for a file path.
<goto10>  I have a button next to the text box which launches the media library.  The problem is that if 
	the custom post type does not have 'editor' within the 'supports' params, the "Insert into Post" button 
	will not appear after the file has uploaded.  It will however, be on both the Gallery and Media Library tabs.
<goto10> I have determined that if I set $send to TRUE right before line 1268 of wp-admin/includes/media.php,
	it works! (The Insert into Post button returns. ...Now trying to figure out how to do that without the core hack.
<sivel> That isn't necessarily a bug.  we define the abiltiy to "send to the editor" by a post type actually having 
	the editor capability, otherwise there really isn't any place to send it
<sivel> 'send' => post_type_supports(get_post_type($post->post_parent), 'editor')
<sivel> although perhaps a filter, that would allow people such as yourself to override that
<sivel> might want to raise a ticket about it
<goto10> Thanks sivel.  Yes, a filter would be very helpful.  The whole "paste in the url" routine for these fields 
	is just not client friendly, and using the media uploader is great for this.
<goto10> cool, I think I will make a ticket.  I would hate to see it disappear on the other tabs on account of me, but
	it seems that if hiding the button is expected behavior, than the  Insert into Post button should not be appearing at all.
<sivel> yeah, and perhaps make it something like:
	'send' => apply_filters('send_to_editor',
	post_type_supports(get_post_type($post->post_parent), 'editor'), get_post_type($post->post_parent))
<goto10> I think that the snippet that you posted also explains why I can't find $send anywhere in the core, other than
	the one instance I pointed out.
<sivel> dunno, just some thoughts
<goto10> cool.  For now, I think my best bet is going to be to load up some css that hides the editor, even though I
	feel horrible doing so :P
<goto10> Is it ok for me to post this discussion with my ticket?
<sivel> then you can do something like:
	add_filter('send_to_editor', 'send_to_editor_posttype');
	function send_to_editor_posttype($send, $post_type) { if ( $post_type == 'my-cool-posttype' ) { $send = true; } return $send; }
<sivel> sure, no problem
<goto10> Ok, thanks and thanks.  I'll give that filter a shot.  (looks sweet!)
<sivel> it may be best placed a little differently, but at least it gets and idea out there 

(edit: cleaned up for posting ticket)

I should also note that as of 3.0-RC2-15136, I am no longer seeing the "Insert into Post" button on any of the Media Uploader's tabs when the editor is not supported, which is more consistent with how things are supposed to work, as explained by sivel.

Change History (4)

#1 @goto10
13 years ago

  • Summary changed from Media Uploader's "Insert into Post" button disappears when editor is removed from custom post type to Media Uploader's "Insert into Post" button disappears when editor is removed from custom post type - requesting addition of filter to override this behavior

#2 @tehfab1
13 years ago

Just voicing that this would be a wonderful thing you guys could do to add in this functionality.

I've integrated the media uploader into a widget, and it is a bit of a bother that the button just up and disappears when I try to upload a new photo.

Oddly enough I can find the "insert into post" button when I'm browsing previously uploaded media files. So its doable for now, but it'll be nicer when we could enable the button regardless of the situation we're in.

I used this blog post to integrate the editor, so you can see a little of what me and others have been trying to accomplish: http://www.webmaster-source.com/2010/01/08/using-the-wordpress-uploader-in-your-plugin-or-theme/

Anyways, just my two cents.

God Bless,
-Dan

#3 @duck_
13 years ago

  • Component changed from General to Media

Related: #13817

Looking like a duplicate of one specific part of #13817. And as mentioned in that ticket the upload should be getting an overhaul in a future release to include greater extensibility.

#4 @nacin
13 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.