WordPress.org

Make WordPress Core

Opened 11 years ago

Closed 10 years ago

Last modified 10 years ago

#14311 closed defect (bug) (fixed)

No media insertion support using the the_editor() function

Reported by: DreadLox Owned by: Gecka
Milestone: 3.3 Priority: normal
Severity: major Version: 3.1
Component: Editor Keywords:
Focuses: 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 11 years ago.
Correctly insert media files in the correct editor

Download all attachments as: .zip

Change History (13)

#1 @DreadLox
11 years ago

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

#2 @dd32
11 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

@Gecka
11 years ago

Correctly insert media files in the correct editor

#3 @Gecka
11 years ago

  • 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

#4 @nacin
11 years ago

  • Type changed from defect (bug) to enhancement

#5 @Gecka
11 years ago

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"

#6 @dd32
11 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.

#7 @Gecka
11 years ago

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

#8 @DreadLox
10 years ago

Couldn't it have made its way to 3.2 ?

#9 @jshindl
10 years ago

  • 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 10 years ago by jshindl (previous) (diff)

#10 @ocean90
10 years ago

  • Keywords has-patch needs-testing 3.2-early removed

Will be fixed with #17144.

#11 @azaozz
10 years ago

  • Resolution set to fixed
  • Status changed from accepted to closed

#12 @azaozz
10 years ago

  • Milestone changed from Future Release to 3.3
Note: See TracTickets for help on using tickets.