In the media_wysiwyg.filter.js file, the create_element
function assumes that the incoming html if an anchor tag must then be wrapping another HTML element.
For example, if you've changed the template for rendering file links out to not include a span or icon or anything, you cannot insert elements into the media wysiwyg.
The fix is pretty simple, just have the js check if the element has children before assigning element to its child value.
Old code
// Parse out link wrappers. They will be re-applied when the image is
// rendered on the front-end.
if (element.is('a')) {
element = element.children();
}
New code
// Parse out link wrappers. They will be re-applied when the image is
// rendered on the front-end.
if (element.is('a') && $(element).children().length > 0) {
element = element.children();
}
See http://cgit.drupalcode.org/media/tree/modules/media_wysiwyg/js/media_wys...
I can provide a patch if the code snippet above is acceptable.
Comment | File | Size | Author |
---|---|---|---|
#1 | media-js_assumes_wrapped_elements-2509030-1.patch | 535 bytes | dshields |
Comments
Comment #1
dshields CreditAttribution: dshields at Canadian Blood Services commentedHere's a patch for this.
Comment #2
Chris Matthews CreditAttribution: Chris Matthews as a volunteer commentedClosing this issue as outdated. However, if you think this issue is still important, please let us know and we will gladly re-open it for review.
sincerely,
- the Drupal Media Team