[wp-trac] [WordPress Trac] #13790: Media Uploader's "Insert into Post" button disappears when editor is removed from custom post type
WordPress Trac
wp-trac at lists.automattic.com
Wed Jun 9 04:26:04 UTC 2010
#13790: Media Uploader's "Insert into Post" button disappears when editor is
removed from custom post type
-------------------------+--------------------------------------------------
Reporter: goto10 | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Unassigned
Component: General | Version:
Severity: normal | Keywords:
-------------------------+--------------------------------------------------
I'm launching the Media Uploader from a button a la: [http://www
.webmaster-source.com/2010/01/08/using-the-wordpress-uploader-in-your-
plugin-or-theme/ 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.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/13790>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list