Setting TinyMCE valid elements
-
I’m working on customizing the default TinyMCE install that comes with WordPress 2.x (in point of fact, I’m working on it in WordPress MU, but the internals are the same).
I’m trying to figure out why I can’t use the “class” attribute of anything in the html editor.
As an example, let’s take an img tag. I want the user to be able to add a class attribute to a tag in the html editor, but everytime I do so it’s stripped out.
I’ve looked in tiny_mce_gzip.php and modified the $vald_elements string, which is where WP is setting the list of valid elements for the tinyMCE_init() procedure call. When I remove an attribute from the list of available attributes for the img element it also gets stripped, so I know this part of it is working, but what’s confusing is that the class attribute is already in the valid element list, and it still get stripped. What’s more, if I add a class to an a tag it’s kept.
The bit that’s allowing the anchor class:
a[accesskey|charset|class|...
The bit that (should be) allowing the img class:
img[alt|border|class|...
Don’t know if it’s relevant, but I can see the class in the path-bar under the TineMCE edit box, for both img and a tags. The stripping happens at save, and after that I can’t see the class in the path-bar or in the html.
Has anyone else successfully applied classes to images? Is there another valid_elements filter I’m missing?
- The topic ‘Setting TinyMCE valid elements’ is closed to new replies.