There is a regex in media_wysiwyg.filter.js that looks for any img or span tags that have a class of media-element. If found, it then attempts to look up the fid and change this element to a media token. If this process fails, the img or span is then replaced with false, instead of leaving the element untouched. Better error detection in this code would gracefully allow the original image to remain untouched if errors were encountered.
Steps to replicate
- Use the WYSIWYG to add a media image to body copy of a node
- Save the node
- When viewing the node, copy the image by select-dragging over the content of the node, including the image.
- Paste the copied content into a new node form with WYSIWYG
- Toggle the Disable Rich Text button to view the markup you pasted
- Toggle the Enable Rich Text button
At this point, the image will be replaced with false.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | media-2631934-media-element-wysiwyg-false-3.patch | 1.35 KB | q0rban |
Comments
Comment #2
q0rban commentedComment #3
q0rban commentedComment #4
q0rban commentedComment #5
jantoine commentedThis is a regression due to a rewrite of the replacePlaceholderWithToken() function. It was originally discovered and fixed in #2320535: Media 7.x-2.0-alpha2 to 7.x-2.x-dev break existing WYSIWYG content. The function was then rewritten in #2307993: WYSIWYG filter removes script tags causing the fix to be lost. I'm also marking this as critical as it causes data loss when simply saving existing content where match is found but a macro fails to be created.
@q0rban,
I have tested your patch in #3 and it fixes the issue, but I have a question and a suggestion before marking RTBC:
Comment #6
marcoka commentedtested it. fixes my problem.
Comment #7
q0rban commentedHi jantoine!
The fix to the classRegex variable ensures a proper match. Consider the following code:
With the regex as it was before, the only class returned would be
foo, because it will match either a double or single closing quote with no verification that it matches the opening quote. The new regex would returnfoo'bar baz, as it ensures the closing quote matches the opening quote. It's tangentially related to the issue, but you can revert it if you'd rather keep it separate.Your documentation change on the comment sounds fine to me as well! :)
Thanks for reviewing.
Comment #8
murz@q0rban, thanks for the patch! It solves the problem with Media images converts to
falseafter dragging in CKEditor. Please commit it to Media core, because this is critical issue! One image move will break all images in document without any way to restore!!!Comment #9
marcoka commentedmajor issue, true. killed a lot of images this way.
Comment #10
othermachines commentedAgree this is critical. We've had to rebuild whole pages from scratch. Patch in #3 seems to have solved the problem for us - thanks!
Comment #11
volker23 commentedPatch works like a charm! Thanks for contributing!
Comment #13
dave reidTested and committed #3 to 7.x-2.x. Thanks!
Comment #15
xaviemirmon@q0rban you are a superstar. #3 needs to be released asap