Opened 10 years ago

Closed 9 months ago

#1245 closed defect (fixed)

it' not possible to enter percent values to height or width attributes of images

Reported by: guest Owned by: gogo
Priority: normal Milestone: 0.97
Component: Xinha Core Version:
Severity: normal Keywords:
Cc:

Description

1) insert an image with the "Insert/Modify? Image" button.

2) switch to the source view

3) add width and/or height attributes to the image tag with percent values e.g.:
<img src="http://www.google.at/intl/de_at/images/logo.gif" alt="google test" width="50%" />

4) swtich back to the wysiwyg view
5) again, switch to the source view

Now the with of the image is an absolute pixle value, in the above case something like:
<img width="436" alt="google test" src="http://www.google.at/intl/de_at/images/logo.gif" />

The Problem seems to be in the modules/GetHtml/DOMwalk.js file.
In this file the line
value = root[a.nodeName];
is used to read the value of the width value, and root[a.nodeName] returns the absolute pixle value.

value = a.nodeValue; would return the correct % value.

Change History (5)

comment:1 Changed 10 years ago by nicholasbs

The above suggestion (using a.nodeValue instead of root[a.nodeName]) works in Safari 3 and FF3, but not IE7, which returns the pixel value for both.

comment:2 Changed 10 years ago by nicholasbs

Looking into this further, DOMwalk.js has some ugly stuff that should be cleaned up, e.g., using the attributes array (see here).

Also, this issue only exists when using DOMWalk, so an immediate workaround is to set xinha_config.getHtmlMethod = 'TransformInnerHTML' in your config file (see here? for details).

comment:3 Changed 10 years ago by ray

Hmm, interesting. Maybe using sth. like

Index: /home/raimund/www/x-all/trunk/modules/GetHtml/DOMwalk.js
===================================================================
--- modules/GetHtml/DOMwalk.js	(revision 1137)
+++ modules/GetHtml/DOMwalk.js	(working copy)
@@ -126,9 +126,11 @@
         html += ((Xinha.isBlockElement(root)) ? ('\n' + indent) : '') + "<" + root.tagName.toLowerCase();
         var attrs = root.attributes;
         
-        for ( i = 0; i < attrs.length; ++i )
+        for ( i in attrs )
         {
-          var a = attrs.item(i);
+          var a = attrs[i];
+          if (typeof a != 'object') continue;
+
           if (typeof a.nodeValue == 'object' ) continue; // see #684
           if (root.tagName.toLowerCase() == "input" 
               && root.type.toLowerCase() == "checkbox" 

would spare us some of the hacks we have now. On the other hand, it's working and has been matured over years, so one more hack to fix this bug would not hurt much

comment:4 Changed 8 years ago by gogo

  • Milestone changed from 0.96 to 0.97

comment:5 Changed 9 months ago by gogo

  • Resolution set to fixed
  • Status changed from new to closed

[1356] Fixes

Note: See TracTickets for help on using tickets.