Ticket #14311 (closed defect (bug): fixed)

Opened 20 months ago

Last modified 7 months ago

No media insertion support using the the_editor() function

Reported by: DreadLox Owned by: Gecka
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

insert_media_in_correct_editor.patch Download (3.2 KB) - added by Gecka 13 months ago.
Correctly insert media files in the correct editor

Change History

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 ?)

  • 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

Gecka13 months ago

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)
  • Type changed from defect (bug) to enhancement

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....

Couldn't it have made its way to 3.2 ?

  • 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.

Last edited 7 months ago by jshindl (previous) (diff)
  • Keywords has-patch needs-testing 3.2-early removed

Will be fixed with #17144.

  • Status changed from accepted to closed
  • Resolution set to fixed
  • Milestone changed from Future Release to 3.3
Note: See TracTickets for help on using tickets.