Moodle
  1. Moodle
  2. MDL-7043

hyperlinking an Image using the HTML Editor does not work.

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.6.3, 1.7, 1.8
    • Fix Version/s: 1.8.3, 1.9
    • Component/s: HTML Editor (TinyMCE)
    • Labels:
      None
    • Affected Branches:
      MOODLE_16_STABLE, MOODLE_17_STABLE, MOODLE_18_STABLE
    • Fixed Branches:
      MOODLE_18_STABLE, MOODLE_19_STABLE
    • Rank:
      27971

      Description

      Hyperlinking an image using the html editor gives strange behaviour using different browsers.....

      In Firefox (I'm using 1.0.7), try this.

      insert an image, give it a useful alt text - eg "image"
      then make sure the image is selected and use the hyperlink button to create a hyperlink for the image.
      for the hyperlink title use some useful text like "URL" - then hit ok.
      Instead of creating a hyperlink, in Firefox, the Image disapears, however the image alt text appears in place of the image as "text" (If that makes sense!)

      In IE 6 you get a JS error like mentioned here:
      http://moodle.org/mod/forum/discuss.php?d=55696

      In IE 7 (Beta 2) you don't get a JS error, but when you try to add a link to an image, the insert Link window doesn't do anything when you hit "OK" - it just sits there, and makes no changes to the underlying window (this is possibly just an IE 7 quirk, - might be improved in the next version....) - I'll upgrade to RC 1 to see If I can get any more debug info out! ( I will upgrade FF as well to see if that makes any difference.

        Issue Links

          Activity

          Hide
          Dan Marsden added a comment -

          In IE 7 RC1 debugging is slightly better - you get the standard runtime error window "object doesn't support this property or method" - refers to Line 1348

          if you actually debug the code it throws a couple of errors:

          Line 76 of lib/editor/htmlarea/dialog.js - This line:

          action(val);

          throws an error "Object doesn't support this property or method"

          if you ignore that error you also get this error:
          Line 1348 (actually line 1387) of lib/editor/htmlarea/htmlarea.php This line:

          range.pasteHTML(html);

          throws an error "object doesn't support this property or method"

          Dan

          Show
          Dan Marsden added a comment - In IE 7 RC1 debugging is slightly better - you get the standard runtime error window "object doesn't support this property or method" - refers to Line 1348 if you actually debug the code it throws a couple of errors: Line 76 of lib/editor/htmlarea/dialog.js - This line: action(val); throws an error "Object doesn't support this property or method" if you ignore that error you also get this error: Line 1348 (actually line 1387) of lib/editor/htmlarea/htmlarea.php This line: range.pasteHTML(html); throws an error "object doesn't support this property or method" Dan
          Hide
          Teresa Gibbison added a comment -

          This is also happening in Moodle 1.7 - I tried to Clone this to change the Moodle version but alas - I need to read the documentation again...
          Teresa

          Show
          Teresa Gibbison added a comment - This is also happening in Moodle 1.7 - I tried to Clone this to change the Moodle version but alas - I need to read the documentation again... Teresa
          Hide
          Olli Salo added a comment -

          This problem occurs also with Firefox 2.0.0.1 and IE7 7.0.5730.11 (we have Moodle 1.6.3+ on Postgresql).

          Olli

          Show
          Olli Salo added a comment - This problem occurs also with Firefox 2.0.0.1 and IE7 7.0.5730.11 (we have Moodle 1.6.3+ on Postgresql). Olli
          Hide
          Dan Poltawski added a comment -

          I've tried something which seems to get it to work in FF2, but not IE currently:
          — htmlarea.php 2007-01-04 16:38:56.000000000 +0000
          +++ htmlarea.php 2007-02-19 12:54:34.000000000 +0000
          @@ -1479,7 +1481,15 @@
          strLink = ' target="' param.f_target.trim() +'"';
          }
          strLink += '>';

          • strLink += (!HTMLArea.is_ie) ? sel : range.text;
            +
            + // UGLY HACK TO FIX 7043
            + var selectedEl = editor.getParentElement();
            + if(selectedEl.tagName.toLowerCase() == 'img') { + strLink+= selectedEl.parentNode.innerHTML; + }

            else

            { + strLink += (!HTMLArea.is_ie) ? sel : range.text; + }

            +
            strLink += '</a>';
            editor.insertHTML(strLink);
            } else {

          Show
          Dan Poltawski added a comment - I've tried something which seems to get it to work in FF2, but not IE currently: — htmlarea.php 2007-01-04 16:38:56.000000000 +0000 +++ htmlarea.php 2007-02-19 12:54:34.000000000 +0000 @@ -1479,7 +1481,15 @@ strLink = ' target="' param.f_target.trim() +'"'; } strLink += '>'; strLink += (!HTMLArea.is_ie) ? sel : range.text; + + // UGLY HACK TO FIX 7043 + var selectedEl = editor.getParentElement(); + if(selectedEl.tagName.toLowerCase() == 'img') { + strLink+= selectedEl.parentNode.innerHTML; + } else { + strLink += (!HTMLArea.is_ie) ? sel : range.text; + } + strLink += '</a>'; editor.insertHTML(strLink); } else {
          Hide
          Charlie Owen (SonniesEdge) added a comment -

          I think this deserves a higher priority than "minor". This is a major interface bug. I've just had to explain to our art lecturers, red-faced, that Moodle can't actually handle making images into links. The Blackboard advocate at the back was crowing with laughter!

          I assume that nothing is being done to address this because of the possibility of switching to TinyMCE as the default editor? (which I hear is now not going to happen for Moodle 1.9...)

          Show
          Charlie Owen (SonniesEdge) added a comment - I think this deserves a higher priority than "minor". This is a major interface bug. I've just had to explain to our art lecturers, red-faced, that Moodle can't actually handle making images into links. The Blackboard advocate at the back was crowing with laughter! I assume that nothing is being done to address this because of the possibility of switching to TinyMCE as the default editor? (which I hear is now not going to happen for Moodle 1.9...)
          Hide
          Tim Hunt added a comment -

          This issue is causing pain for our users, so I am probably going to have to try to fix it this week. From the comments I just read on some of the duplicate bugs, it seems that this used to work in Moodle 1.5, so I guess a place to start is seeing what has changed since then.

          Show
          Tim Hunt added a comment - This issue is causing pain for our users, so I am probably going to have to try to fix it this week. From the comments I just read on some of the duplicate bugs, it seems that this used to work in Moodle 1.5, so I guess a place to start is seeing what has changed since then.
          Hide
          Tim Hunt added a comment -

          OK, as we know HTMLarea is officially dead, but lives on as Xinha (http://xinha.webfactional.com/).

          Images and links seems to be working in the latest version of Xinha, and the code is at around like 80 of http://xinha.webfactional.com/browser/trunk/plugins/InsertAnchor/insert-anchor.js

          Compare that to to code at about line 1550 of lib/editor/htmlarea/htmlarea.php

          I'm going to try merging that into Moodle. Wish me luck.

          Show
          Tim Hunt added a comment - OK, as we know HTMLarea is officially dead, but lives on as Xinha ( http://xinha.webfactional.com/ ). Images and links seems to be working in the latest version of Xinha, and the code is at around like 80 of http://xinha.webfactional.com/browser/trunk/plugins/InsertAnchor/insert-anchor.js Compare that to to code at about line 1550 of lib/editor/htmlarea/htmlarea.php I'm going to try merging that into Moodle. Wish me luck.
          Hide
          Tim Hunt added a comment -

          Actually, I was wrong, it is http://xinha.webfactional.com/browser/trunk/modules/CreateLink/link.js that I need to merge the code from.

          Show
          Tim Hunt added a comment - Actually, I was wrong, it is http://xinha.webfactional.com/browser/trunk/modules/CreateLink/link.js that I need to merge the code from.
          Hide
          Dan Poltawski added a comment -

          Looks like editor.getSelection() is the key bit misisng?

          Show
          Dan Poltawski added a comment - Looks like editor.getSelection() is the key bit misisng?
          Hide
          Tim Hunt added a comment -

          Unfortunately, both I and a colleague tried this week, and failed to make it work. I think we are going to have to admit defeat for now.

          At some point someone is going to have to take the plunge and integrate a different, supported, editor.

          Show
          Tim Hunt added a comment - Unfortunately, both I and a colleague tried this week, and failed to make it work. I think we are going to have to admit defeat for now. At some point someone is going to have to take the plunge and integrate a different, supported, editor.
          Show
          Matt Clarkson added a comment - Bug is fixed in CVS - a diff of the bug fix is available below: http://git.catalyst.net.nz/gitweb?p=moodle-r2.git;a=blobdiff;h=f18ac67119d3ed30a6790b955c8f11d7c358d4c8;hp=1ec349e8f8cd51a442c2b69b42af17e705a428c9;hb=d004a5c4282997dd3dab8f6f4a345e65c2b1ce8b;f=lib/editor/htmlarea/htmlarea.php
          Hide
          Dan Poltawski added a comment -

          Thanks Matt!

          I've just verified that fix is working on Firefox 2.0 Win/Linux, IE 6, IE 7

          Show
          Dan Poltawski added a comment - Thanks Matt! I've just verified that fix is working on Firefox 2.0 Win/Linux, IE 6, IE 7
          Hide
          Jean-Pierre Pawlak added a comment -

          I applied this fix to our 1.6.5+ version.
          It works fine. Thx.
          Found out however the remove link option doesn't work
          and it's impossible to change the link using Firefox 2.
          IE 7 let's me remove the link but asks to select text if I want to ad a new link.

          Show
          Jean-Pierre Pawlak added a comment - I applied this fix to our 1.6.5+ version. It works fine. Thx. Found out however the remove link option doesn't work and it's impossible to change the link using Firefox 2. IE 7 let's me remove the link but asks to select text if I want to ad a new link.

            People

            • Votes:
              8 Vote for this issue
              Watchers:
              16 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: