Utilizing the contentEditable
feature for rich text editing on my app has been quite the journey. I recently discovered a peculiar issue when inserting and resizing images within the editor.
<img style="width:55px;height:55px" width="100" height="100" src="pic.gif" border=0/>
Surprisingly, certain inserted images had an unexpected "rogue" style attribute and parameter attached to them. However, this only seemed to affect the rendering in IE7, where the image was displayed at the intended 55px x 55px size.
Upon exporting the content to a MS Word document, I noticed that all resized images reverted back to their original dimensions. It turns out that MS Word disregards the inline styles and reverts to the default image size specified in the HTML attributes.
After some investigation, I developed a JavaScript function to extract the style width and height values and transfer them to the img tag directly before saving the content to the database. This resolved the sizing discrepancies encountered during export.
Cheers!
Oh, one more thing... My recommendation is to keep both attributes directly under the img tag rather than using the style attribute.