Opened 3 years ago

Closed 22 months ago

Last modified 22 months ago

#14311 closed defect (bug) (fixed)

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

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

Download all attachments as: .zip

Change History (13)

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

comment:2   dd322 years ago

  • Keywords needs-patch added; editor meta-boxes wysiwyg the_editor removed
  • Milestone changed from Awaiting Review to Future Release
  • Type changed from defect (bug) to enhancement

Gecka2 years ago

Correctly insert media files in the correct editor

  • Keywords has-patch added; needs-patch removed
  • Owner set to Gecka
  • Status changed from new to accepted
  • Type changed from enhancement to defect (bug)
  • Version changed from 3.0 to 3.1
  • 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"

comment:6   dd322 years ago

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

Version 0, edited 23 months ago by jshindl (next)
  • Keywords has-patch needs-testing 3.2-early removed

Will be fixed with #17144.

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