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
Comment #1
eigentor CreditAttribution: eigentor commentedComment #2
TwoDThis 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 infalse
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:
Comment #3
drupauler CreditAttribution: drupauler commented> This new filter has caused a lot of grief for users so far.
Amen to that. Thanks for the workround.
Comment #4
sylus CreditAttribution: sylus commentedWorks great and solves http://drupal.org/node/1951964
Comment #5
sylus CreditAttribution: sylus commentedI have found that the following works which is a bit less of a hammer approach:
Comment #6
Frank Pfabiganthis issue is linked to: http://drupal.org/node/1951964
solution is to write a custom module that fixes the issue. here is the code:
Comment #7
bsarchive CreditAttribution: bsarchive commentedHooray! Thanks Frank Pfabigan.
Comment #8
deggertsen CreditAttribution: deggertsen commentedThank 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?
Comment #9
dan_lennox CreditAttribution: dan_lennox commented"$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.
Comment #10
ThaJoa CreditAttribution: ThaJoa commentedNeither #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).
Comment #11
TwoDIn #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.
Comment #12
ThaJoa CreditAttribution: ThaJoa commentedYou 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.
Comment #13
Kristen PolI 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.
Comment #14
spfaffly CreditAttribution: spfaffly commentedFrank Pfabigan's solution #6 worked perfectly for me. Thanks!
Comment #15
galgeek CreditAttribution: galgeek commentedI am yet another relieved and satisfied user of Frank Pfabigan's #6
Comment #16
TwoDOk, 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.
Comment #17
TwoDComment #18
margaux CreditAttribution: margaux commentedThanks, @Frank Pfabigan! This was exactly what I needed, too.
Comment #19
tadesign CreditAttribution: tadesign commentedThank 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!
Comment #20
FiNeX CreditAttribution: FiNeX commentedWith the latest wysiwyg -dev release the module suggested on comment #9 is no more needed. I suggest to close this bug.
Comment #21
kenorb CreditAttribution: kenorb commentedSee also:
http://drupal.stackexchange.com/questions/74778/ckeditor-removes-class-n...
Comment #22
PascalAnimateur CreditAttribution: PascalAnimateur commentedI 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]
Comment #23
bircherTo use the automatic ACF I added the following to the setting:
mediawrapper[!data];*[!data-file_info]
and the media elements didn't get turned to false any more.
Comment #24
PascalAnimateur CreditAttribution: PascalAnimateur commentedStrangely the latest -dev of file_entity / media don't seem to work with the previous two ACF rules. What I now have to use in order to have teaser break + all the media file types working:
img[title,alt,src,data-cke-saved-src](wysiwyg-break,drupal-content);video[width,height,controls,src](*);audio[controls,src](*);img[*](media-element,file-default)
Comment #25
dw72 CreditAttribution: dw72 commentedI still have "false" with settings from #24. Can I insert it in 'Content rules' field in wysiwyg module settings or must use own module for this?
Comment #26
TwoDThis is the downside to having to manually specify the content rules. Modules can change how they do things (maybe just in some situations) behind your back...
I wrote a patch ago to allow modules to add rules on their own. I think I've uploaded it but I can't find it now. I'll create a new issue as a follow-up to this one if I can't find it.
Comment #27
alex.skrypnykAdded
<source>
tag to rules above. Updated code below.Comment #28
MurzThis problem is sometimes happens on fresh Media and CKEditor module - not each time, but at random. Seems that provided solutions is for Wysiwyg module, did you have solution for CKEditor module?
Comment #29
Murz#28, seems that this is another issue #2631934: Images or spans with class media-element are converted to "false" in WYSIWYG
Comment #30
lsbbs CreditAttribution: lsbbs as a volunteer commentedI added to pictures with entity view modes and file entity an additional field to the image to display a caption text.
After applying the patch mentioned here in #6 this was working fine with ckeditor 4.3.0.1e748a6.
Now I added a second field for photographers credits which should be a link.
In the editor it looks then like this:
[[{"fid":"19","view_mode":"story_image_left","fields":{"format":"story_image_left","field_file_image_alt_text[und][0][value]":"Hazabe","field_file_image_title_text[und][0][value]":"Hazabe","field_caption[und][0][value]":"Hazabe after hunting","field_photo[und][0][title]":"Gideon Shea","field_photo[und][0][url]":""},"type":"media","attributes":{"alt":"Hazabe","title":"Hazabe","height":"213","width":"320","class":"media-element file-story-image-left"}}]]
As long the url part of field_photo is empty it is displayed like wanted.
When I enter there a URL the entire picture with caption text disappears from the output.
I have actual no clue where to check why the URL is filtered out.
Help or hints are appreciated.
Comment #31
alimc29 CreditAttribution: alimc29 commentedJust adding a comment here to hopefully help anyone who might need it - CKEditor ACF - http://docs.ckeditor.com/#!/guide/dev_advanced_content_filter - also has a disallowedContent setting.
We tried the other suggestions for one of our sites, but its configuration was so complex that was creating issues - specifically because we were using the ckeditor_image2 module and needed it to be able to control left/center/right alignment and captions, but we were also trying to work with media_youtube, and our videos would not work without
$settings['allowedContent'] = TRUE;
, but this created issues for the ckeditor_image2 integration, and I couldn't figure out the proper tag to use for the videos inserted via media_wysiwyg/media_youtube combination.Because we wanted to be able to use the media tokens, but allow the user to control the image properties via the wysiwyg, we ended up with the following:
Comment #32
fadeslayer CreditAttribution: fadeslayer commentedI have replied to this (https://www.drupal.org/node/1965536#comment-11543537) which seems related to this one.
Comment #33
joseph.olstad#27 works for me
didn't require any custom module either, just added the settings
img[title,alt,src,data-cke-saved-src](wysiwyg-break,drupal-content);video[width,height,controls,src](*);source[src,type];audio[controls,src](*);img[*](media-element,file-default)
to the Cleanup and Output 'Content Rules'
/admin/config/content/wysiwyg/profile/editor
and because our client wants to preserve font styles in paste from word items , precede this with properties;
so:
properties;img[title,alt,src,data-cke-saved-src](wysiwyg-break,drupal-content);video[width,height,controls,src](*);source[src,type];audio[controls,src](*);img[*](media-element,file-default)
works as well.
ACF configuration is important because in ckeditor >=4.6.x ACF configuration is required for the paste from word plugin to work properly (or paste from LibreOffice ). The ACF must be configured correctly because the paste from word plugin relies on ACF. However if ACF is not correctly configured the media browser in wysiwyg will not work correctly.