<![CDATA[ TinyMCE - adding a link to an image not working - MODX Community Forums]]> https://forums.modx.com/thread/?thread=85328 <![CDATA[TinyMCE - adding a link to an image not working]]> https://forums.modx.com/thread/85328/tinymce---adding-a-link-to-an-image-not-working?page=2#dis-post-470570 MODX Revolution 2.2.8-pl (traditional)
PHP Version 5.3.24
Running on an apache server

When using TinyMCE, I've inserted an image, selected that image, and clicked the insert/edit hyperlink button. The window pops up and I add the URL of where I want the image to link to. Then I click update. Instead of closing the popup window and adding the hyperlink - the popup window shows up again, without the URL I've just added, and the link isn't added to the image. Any suggestions/ideas?
htjeerdsma Jul 02, 2013, 01:33 AM https://forums.modx.com/thread/85328/tinymce---adding-a-link-to-an-image-not-working?page=2#dis-post-470570
<![CDATA[Re: TinyMCE - adding a link to an image not working]]> https://forums.modx.com/thread/85328/tinymce---adding-a-link-to-an-image-not-working?page=2#dis-post-522996 wishbone Mar 19, 2015, 06:03 AM https://forums.modx.com/thread/85328/tinymce---adding-a-link-to-an-image-not-working?page=2#dis-post-522996 <![CDATA[Re: TinyMCE - adding a link to an image not working]]> https://forums.modx.com/thread/85328/tinymce---adding-a-link-to-an-image-not-working#dis-post-520193 jmaddington2 Feb 07, 2015, 04:32 PM https://forums.modx.com/thread/85328/tinymce---adding-a-link-to-an-image-not-working#dis-post-520193 <![CDATA[Re: TinyMCE - adding a link to an image not working]]> https://forums.modx.com/thread/85328/tinymce---adding-a-link-to-an-image-not-working#dis-post-515419
I was able to find a fix for this issue, but you guys won't like it. The fix is actually inside tinymce repo on github and you just have to transfer it to modx. Follow this steps to get your links work properly on img in webkit browsers:

1. Go to tinymce repo and find EditorCommands.js. The version I used is here https://github.com/tinymce/tinymce/blob/7d42a92f11812661a48c8d105c8336824795848e/jscripts/tiny_mce/classes/EditorCommands.js
2. We need to use mceInsertLink (somewhere around line 355).
3. Now we need to copy/paste it to modx's tinymce and here's the tricky part. The whole library is minified in /assets/components/tinymce/jscripts/tiny_mce/tiny_mce.js so you have to beautify it first (or not if you are super accurate) and replace mceInsertLink's function with one from github.
4. Once you've done that go to the script that caused error /assets/components/tinymce/jscripts/tiny_mce/plugins/modxlink/js/modxlink.js and find there inside insertAction().
tinyMCEPopup.execCommand("CreateLink", false, "#mce_temp_url#",{
            skip_undo : 1

You should change the name of the command to fresh mceInsertLink
tinyMCEPopup.execCommand("mceInsertLink", false, "#mce_temp_url#", {
            skip_undo : 1

5. Minify your tiny_mce.js again if you want. Placing links should work for you now. I've tested it on both local and production server already.]]>
dasmart Nov 21, 2014, 08:39 PM https://forums.modx.com/thread/85328/tinymce---adding-a-link-to-an-image-not-working#dis-post-515419
<![CDATA[Re: TinyMCE - adding a link to an image not working]]> https://forums.modx.com/thread/85328/tinymce---adding-a-link-to-an-image-not-working#dis-post-513718 Quote from: Magnatron at Oct 27, 2014, 01:56 PM
Heather. Matdave, did you ever find anything? I am running into the exact same problem.

Magnatron, I found that using Firefox fixed it. Seems to only happen on Chrome, and only when the image is at the *top* of the page.]]>
matdave Oct 30, 2014, 03:25 PM https://forums.modx.com/thread/85328/tinymce---adding-a-link-to-an-image-not-working#dis-post-513718
<![CDATA[Re: TinyMCE - adding a link to an image not working]]> https://forums.modx.com/thread/85328/tinymce---adding-a-link-to-an-image-not-working#dis-post-513488 Magnatron Oct 27, 2014, 08:56 AM https://forums.modx.com/thread/85328/tinymce---adding-a-link-to-an-image-not-working#dis-post-513488 <![CDATA[Re: TinyMCE - adding a link to an image not working]]> https://forums.modx.com/thread/85328/tinymce---adding-a-link-to-an-image-not-working#dis-post-486783 matdave Jan 08, 2014, 09:13 AM https://forums.modx.com/thread/85328/tinymce---adding-a-link-to-an-image-not-working#dis-post-486783 <![CDATA[Re: TinyMCE - adding a link to an image not working]]> https://forums.modx.com/thread/85328/tinymce---adding-a-link-to-an-image-not-working#dis-post-470689
TypeError: 'null' is not an object (evaluating 'elm.childNodes')
in file: /assets/components/tinymce/jscripts/tiny_mce/plugins/modxlink/js/modxlink.js
line 424

This is the section of code that's causing the error:

    // Don't move caret if selection was image
    if (elm.childNodes.length != 1 || elm.firstChild.nodeName != 'IMG') {

It's the if statement that is on line 424.

Any ideas to fix this?]]>
htjeerdsma Jul 03, 2013, 04:35 AM https://forums.modx.com/thread/85328/tinymce---adding-a-link-to-an-image-not-working#dis-post-470689
<![CDATA[Re: TinyMCE - adding a link to an image not working]]> https://forums.modx.com/thread/85328/tinymce---adding-a-link-to-an-image-not-working#dis-post-470682 sottwell Jul 03, 2013, 04:01 AM https://forums.modx.com/thread/85328/tinymce---adding-a-link-to-an-image-not-working#dis-post-470682 <![CDATA[Re: TinyMCE - adding a link to an image not working]]> https://forums.modx.com/thread/85328/tinymce---adding-a-link-to-an-image-not-working#dis-post-470679
I have completely uninstalled and removed TinyMCE, cleared the cache folder manually, flushed sessions, cleared browser cache, closed the browser ... and then reinstalled TinyMCE. Still the same problem. I've attached an image show what it looks like.
And when I look at the HTML - nothing looks odd, for example, here is the HTML of the page I am working with:

<h3><img class="left" src="assets/sitefiles/images/harperpark-creekfall.jpg" alt="Harper Park - creek" width="250" height="336" />Trail Systems</h3>
<p>Create trails and boardwalks that protect sensitive wetlands, but also allow viewing of native wildlife and plants. These trails will be accessible to persons of all ages and abilities.</p>
<h3>Bird Watching</h3>
<p>Develop a birding checklist to help birders identify local species, sharing our discoveries with others.</p>
<h3>Educational Programs</h3>
<p>Provide resources so families can learn about, and enjoy nature together, developing a life-time of shared interest in the world around them.</p>

After I try to insert a link for the image, the HTML isn't changed at all. I only get the pop up window showing again like the image I've attached.

... After some more playing around with it in different browsers, I've found that it works properly in Firefox but the problem occurs in Chrome and Safari.]]>
htjeerdsma Jul 03, 2013, 01:52 AM https://forums.modx.com/thread/85328/tinymce---adding-a-link-to-an-image-not-working#dis-post-470679