Inserting link in TinyMCE on centered image produces js error

Permalink
Has anyone found a workaround for this problem? If I have the following code in a content block:

<p><img style="margin-right: auto; margin-left: auto; display: block;" src="/index.php/download_file/view_inline/385/" alt="myimage.jpg" width="536" height="239" /></p>


...and I try to make it a link (by clicking on the chain icon), when I click update, the form just stays open, and I get the following error in the console:

Uncaught TypeError: Cannot read property 'childNodes' of null

This was supposed to have been fixed in versions of TinyMCE earlier than the one shipped with Concrete 5.5.2.1 (TinyMCE 3.4.6). This only happens in Chrome from what I can tell. Also, note if I take out the style="" attribute, the link inserts fine...

blakeage
 
muhlegg replied on at Permalink Reply
Same issue here, cannot insert links for items aligned to the right.
blakeage replied on at Permalink Reply
blakeage
Yea, I think we just removed the style from the image and it worked.
BOLVERIN replied on at Permalink Reply
BOLVERIN
If you want fix this:
open file concrete\js\tiny_mce\plugins\advlink\js\advlink.js

search line 381
and replace function insertAction() with this code:
function insertAction() {
   var inst = tinyMCEPopup.editor;
   var elm, elementArray, i;
   elm = inst.selection.getNode();
   if(elm.nodeName == 'IMG') {
      var imgEl = elm;
      var elmStyleCSSText = elm.style.cssText;
      elm.style.cssText = '';
   }
   checkPrefix(document.forms[0].href);
   elm = inst.dom.getParent(elm, "A");
   // Remove element if there is no href
   if (!document.forms[0].href.value) {
      tinyMCEPopup.execCommand("mceBeginUndoLevel");
      i = inst.selection.getBookmark();
BOLVERIN replied on at Permalink Reply
BOLVERIN
it's correct work on 5.6.1.2 version Concrete5 and 3 major version TinyMCE
remember — replace full function
tristan39x39 replied on at Permalink Reply
If "float: right" or "float: left" is applied to the image class, it does not work :-( To work fine you should also remove class from the image...


function insertAction() {
   var inst = tinyMCEPopup.editor;
   var elm, elementArray, i;
   elm = inst.selection.getNode();
   if (elm.nodeName == 'IMG') {
         var imgEl = elm;
         var elmStyleCSSText = imgEl.style.cssText;
         imgEl.style.cssText = '';
   var ImgclassName = imgEl.className;
   imgEl.className = '';
   }
   checkPrefix(document.forms[0].href);
   elm = inst.dom.getParent(elm, "A");
   // Remove element if there is no href
   if (!document.forms[0].href.value) {