TinyMCE adding attributes that cause validation to fail when inserting images
Posted: 12 June 2007 10:04 PM   [ Ignore ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  600
Joined  11-07-2004

I did some research on this before posting.

Normally, to stop TinyMCE from adding attributes, you’d go to the tiny_mce_init.js file.

You’d remove the attributes vspace, hspace and border since they aren’t valid XHTML Strict attribs.

I am using TinyMCE as an extension. Which removes the init line completely. Since that’s gone, they have a text box in the extension handler to add/remove things. HOWEVER. the documentation link points back to the moxie site, which after searching the forums, results to the init file that doesn’t exist.

Confused yet? I am.

Bottom line, I need to know WHERE to go to remove the attributes that TinyMCE is adding to my9 images.

What’s worse, I can view the HTML of the entry right? if I remove the border=“0” which is there by defualt, it puts it right back in after correcting the HTML.

There’s no documentation or links I could find to who wrote this extension, though I probably didn’t look hard enough, but this should be an extremely easy thing to fix. but since the EE extension appears to change the way that TinyMCE is called, i can’t see the options.

Can anyone helP?

 Signature 

Member: ExpressionEngine Pro Network: ePlaces Network Services

ePlaces Network Services

Profile
 
 
Posted: 13 June 2007 01:10 AM   [ Ignore ]   [ # 1 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  600
Joined  11-07-2004

OK I figured this out.

What you have to do is go into the extension settings. Add ALL of the attributes you want TinyMCE to utilize. you have to configure this correctly too or it won’t work.

Here’s what I changed mine to. I removed the align and border options from the img tag and it worked great. I also added style= so I could manually put the style in to float the image left or right. This does pass XHTML Strict validation too.

valid_elements : "" +
"+a[id|style|rel|rev|charset|hreflang|dir|lang|tabindex|accesskey|type|name|href|target|title|class|onfocus|onblur|onclick|" +
    
"ondblclick|onmousedown|onmouseup|onmouseover|onmousemove|onmouseout|onkeypress|onkeydown|onkeyup]," +
"-strong/-b[class|style]," +
"-em/-i[class|style]," +
"-strike[class|style]," +
"-u[class|style]," +
"#p[id|style|dir|class|align]," +
"-ol[class|style]," +
"-ul[class|style]," +
"-li[class|style]," +
"br," +
"img[id|dir|lang|longdesc|usemap|style|class|src|onmouseover|onmouseout|alt=|title|style=|hspace|vspace|width|height]," +
"-sub[style|class]," +
"-sup[style|class]," +
"-blockquote[dir|style]," +
"-table[border=0|cellspacing|cellpadding|width|height|class|align|summary|style|dir|id|lang|bgcolor|background|bordercolor]," +
"-tr[id|lang|dir|class|rowspan|width|height|align|valign|style|bgcolor|background|bordercolor]," +
"tbody[id|class]," +
"thead[id|class]," +
"tfoot[id|class]," +
"-td[id|lang|dir|class|colspan|rowspan|width|height|align|valign|style|bgcolor|background|bordercolor|scope]," +
"-th[id|lang|dir|class|colspan|rowspan|width|height|align|valign|style|scope]," +
"caption[id|lang|dir|class|style]," +
"-div[id|dir|class|align|style]," +
"-span[style|class|align]," +
"-pre[class|align|style]," +
"address[class|align|style]," +
"-h1[id|style|dir|class|align]," +
"-h2[id|style|dir|class|align]," +
"-h3[id|style|dir|class|align]," +
"-h4[id|style|dir|class|align]," +
"-h5[id|style|dir|class|align]," +
"-h6[id|style|dir|class|align]," +
"hr[class|style]," +
"-font[face|size|style|id|class|dir|color]," +
"dd[id|class|title|style|dir|lang]," +
"dl[id|class|title|style|dir|lang]," +
"dt[id|class|title|style|dir|lang]"

This is listed in their wiki. There’s also advanced attribs you can use. but for my use this was plenty.

As you can see by the list, i could have trimmed this down a LOT. but remember, anything you remove from here will not be available and will be stripped when you try posting them. There are still lots of attributes here that wont pass. Like cellpadding etc. but i didn’t bother removing everything. I will, but for now my goal was to get rid of the align and border commands, and this worked.

 Signature 

Member: ExpressionEngine Pro Network: ePlaces Network Services

ePlaces Network Services

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1149, on July 16, 2007 09:33 AM
Total Registered Members: 65027 Total Logged-in Users: 46
Total Topics: 82117 Total Anonymous Users: 17
Total Replies: 441316 Total Guests: 209
Total Posts: 523433    
Members ( View Memberlist )