This is a problem with TinyMCE 3.0. They don’t currently have align attribute working properly, so they’ve substituted float: left; to temporarily solve this problem. “float” is applied to the image using the “style” tag, but the base install on TinyMCE does not come with the option to add style attributes to images, so you have to add it into the list of usable tags using the ‘extended_valid_elements‘ settings.

Achieving this in Drupal is easy: go to the plugin_reg.php file which is located in your TinyMCE module directory. Find the line that says

$plugins['advimage']['extended_valid_elements'] = array('img[class|src|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name]');

and make sure you add |style to the very end, like so:

$plugins['advimage']['extended_valid_elements'] = array('img[class|src|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name|style]');

If you’re using TinyMCE with any other software, I suggest doing a search for ‘extended_valid_elements’ and see if you can find where it’s being defined for ‘img‘. It probably looks very similar to this everywhere.

1 reply

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *