Ticket #14311 (closed defect (bug): fixed)
No media insertion support using the the_editor() function
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Priority: | normal | Milestone: | 3.3 |
| Component: | Editor | Version: | 3.1 |
| Severity: | major | Keywords: | |
| Cc: |
Description
Hello,
Making, for example, a custom PostType, I needed a rich text text-area in my meta-boxes.
I found the the_editor() function witch is pretty nice. It outputs a tinymce editor with a custom id. That is nice and ok.
Trouble comes when using the $media_buttons parameter to have for example images upload/insertion into the rich text text-area.
It partially works: the buttons get displayed and clicking on them shows up the media upload windows. The problem is that the media upload/insertion window is "tight" to a text-area witch ID is 'content'. (found one occurrence in media-upload.dev.js line 62)
It should be "tight" to the ID provided to the_editor() function.
regards.
Attachments
Change History
- Keywords needs-patch added; editor, meta-boxes, wysiwyg, the_editor removed
- Type changed from defect (bug) to enhancement
- Milestone changed from Awaiting Review to Future Release
-
attachment
insert_media_in_correct_editor.patch
added
Correctly insert media files in the correct editor
- Keywords has-patch added; needs-patch removed
- Owner set to Gecka
- Version changed from 3.0 to 3.1
- Status changed from new to accepted
- Type changed from enhancement to defect (bug)
I have added the patch. It is small and reliable, thus I do not see any reason to not solve it for 3.1 release.
One issue to solve is the point 2: "the get_media_item function will not show an "insert into article" button unless the posttype has the "editor" capability"
- Keywords needs-testing 3.2-early added
thus I do not see any reason to not solve it for 3.1 release.
3.1 is in RC status, new enhancements will not make it in, If it works, check back in a few weeks once we're working on 3.2 to remind someone to check it.
Can you explain me how this is an 'enhancement' and not a bug?
Here is the function definition:
the_editor($content, $id = 'content', $prev_id = 'title', $media_buttons = true, $tab_index = 2)
So any developer using it with a custom $id and $media_buttons to true will expect the media buttons to work with that custom editor. Witch is not the case. Thus this is a bug to me....
- Type changed from enhancement to defect (bug)
This issue affects a plugin we are working with. The patch still works with the latest version of Wordpress. It would be great to get this fixed.
comment:10
ocean90 — 7 months ago
- Keywords has-patch needs-testing 3.2-early removed
Will be fixed with #17144.
comment:11
azaozz — 7 months ago
- Status changed from accepted to closed
- Resolution set to fixed

Having a deep look to it, here is what to be changed to have it work:
1) media-upload.dev.js line 62:
if ( typeof tinyMCE != 'undefined' && tinyMCE.activeEditor ) { tinyMCE.get('content').focus(); tinyMCE.activeEditor.windowManager.bookmark = tinyMCE.activeEditor.selection.getBookmark('simple'); }'content' should be replaced with a variable sent when clicking the media upload button and should reflect the Id parameter of the_editor() function
2) by default the get_media_item function will not show an "insert into article" button unless the posttype has the "editor" capability (wp-admin/includes/media.php line 1166, it still can be overwritten using the $args argument) There should be a workaround to have it enabled even if editor capability is not set for a posttype (additional argument to the_editor function ?)