This issue has been there before with other versions and other editors http://drupal.org/node/1835826#comment-6783518
I understand the CKeditor 4 integration is brandnew and so issues can arise.

If you insert an image via the Media Browser, it first inserts the image fine. But when you save or switch to source code, you just get a "false" instead of the media tag, which should be something like
[[{"fid":"3","view_mode":"default","type":"media","attributes":{"height":276,"width":300,"class":"media-element file-default"}}]]

Using CKeditor 3.6.x fixed the problem for me. So it must be the brandnew CKeditor 4 JS that is causing the issue. Maybe it does not like the formatting of Media tags.

Comments

Title:CKeditor 4 converts Media tags to "false"CKeditor 4 converts Media tags to string "false"

This happens because the new content filter in CKEditor 4 removes Media's data-file_info attribute from its placeholders. That attribute holds the macro representation of the media file and failing to parse it results in false being returned instead.

This new filter has caused a lot of grief for users so far.

A workaround is to disable it completely by implementing hook_wysiwyg_editor_settings_alter() in a small module until we can find a more permanent solution:

<?php
/**
* Implements hook_wysiwyg_editor_settings_alter().
*/
function MYMODULE_wysiwyg_editor_settings_alter(&$settings, $context) {
  if (
$context['profile']->editor == 'ckeditor') {
   
$settings['allowedContent'] = TRUE;
  }
}
?>

> This new filter has caused a lot of grief for users so far.

Amen to that. Thanks for the workround.

Works great and solves http://drupal.org/node/1951964

I have found that the following works which is a bit less of a hammer approach:

<?php
/**
* Implements hook_wysiwyg_editor_settings_alter().
*/
function MYMODULE_wysiwyg_editor_settings_alter(&$settings, $context) {
  if (
$context['profile']->editor == 'ckeditor') {
     
$settings['extraAllowedContent'] = array(
       
'img[src,title,alt,style,width,height,class,hspace,vspace,view_mode,format,fid]',
      );
  }
}
?>

this issue is linked to: http://drupal.org/node/1951964

solution is to write a custom module that fixes the issue. here is the code:

  1. create a folder "wysiwygpatch" in /sites/all/modules.
  2. inside: create a file "wysiwygpatch.info" with this content:
    name = Wysiwyg Patch
    description = Patch for WYSIWYG, http://drupal.org/node/1963270#comment-7267744
    package = User interface
    dependencies[] = wysiwyg
    core = 7.x
    files[] = wysiwygpatch.module
  3. create another file "wysiwygpatch.module" with this content:
    <?php
    /**
    * Implements hook_wysiwyg_editor_settings_alter().
    */
    function wysiwygpatch_wysiwyg_editor_settings_alter(&$settings, $context) {
      if ($context['profile']->editor == 'ckeditor') {
        $settings['allowedContent'] = TRUE;
      }
    }
  4. enable the module. media button should work now.

Hooray! Thanks Frank Pfabigan.

Thank you @Frank Pfabigan.

It would still be nice to have a permanent solution. I assume that there is something useful with CKeditors new filter? If not then maybe it should be disabled in this module by default. Thoughts?

"$settings['allowedContent'] = True" was causing me issues after saving the node. But sylus's version in #5 worked for me.

Slight modification below to allow inserting links to generic files.

<?php
/**
* Implements hook_wysiwyg_editor_settings_alter().
*/
function MYMODULE_wysiwyg_editor_settings_alter(&$settings, $context) {
  if (
$context['profile']->editor == 'ckeditor') {
     
$settings['extraAllowedContent'] = array(
       
'img[src,title,alt,style,width,height,class,hspace,vspace,view_mode,format,fid]',
       
'a[type,length,href]',
      );
  }
}
?>

Neither #6 or #9 is working for me.

I'm using the latest WYSIWYG & media dev versions with the latest full version of ckeditor.
Having the same issue with TinyMCE 3.8 (WYSIWYG).

In #6; the line starting with "files" is not needed since the .module file will always be loaded.
Disabling ACF completely, which is what #6 does, should take care of the problem with Media's content being turned into "false" without issues. If something happens after a node is saved, something else is at work since Wysiwyg only runs PHP code when the form is being built and JS code before the form is submitted.

Once I or someone else gets around to working on #1956778: Ckeditor 4.1 ACF, we'll have a way to control ACF from the GUI and this should be significantly easier to deal with. I'm aiming to have that done before the next release, since CKEditor 4 support will be "officially" introduced then as well.

You were right.

I was able to fix it by editing the text format's filter processing order.
I had to put ''Converts video tags to embedded code'' (from the video module) after the ''convert Media tags to markup'' option.

#6 now works for me.

I tried the more secure (?) version in #5 but it didn't work for me (I did clear the cache) so I went with the bulldozer approach in #6 and it did work ;) For the site in question, the bulldozer is fine... trusted users are using the wysiwyg.

Frank Pfabigan's solution #6 worked perfectly for me. Thanks!

I am yet another relieved and satisfied user of Frank Pfabigan's #6

Ok, I'm calling this a duplicate of #1956778: Ckeditor 4.1 ACF then, but I'll keep it open to be more visible in the queue for a little while.

Status:Active» Closed (duplicate)

Thanks, @Frank Pfabigan! This was exactly what I needed, too.

Thank you very much Frank Pfabigan for the module, that did the trick on a soon to be going live site and saved me hours of frustration!

Happy New Year all!

Issue summary:View changes

With the latest wysiwyg -dev release the module suggested on comment #9 is no more needed. I suggest to close this bug.

I figured out I should post here about how I got media 2.x video and audio to work with CKEditor ACF.
It's as simple as adding the following content rule :
video[controls];audio[controls];source[src,type]