Wednesday, December 23, 2009

TinyMCE - Strict XML Compliance

So I thought I was done.

I am always wrong about that.

Joomla is setup and the sample content has been written up and I thought I was done. But this project requires Strict XML Compliance. I have no idea why except that it does. So I make my way over to the w3c validator. Oh my I have errors.  Cue rolling eyes AND .  So I begin my attempt to clean up my html.  It is pretty clean to begin with but not for Mr. Validator!

The Errors
First few errors are easy.  <br />
are not allowed outside of a block tag.  Hmmm, what is that doing there anyways? Oh, thanks Joomla.  Ok, clean that up and next. <input />tags not allow outside of a block tag....huh? didn't I already have this problem.  Oh, thanks again Joomla.  Ok, that is fixed and now the really easy error to fix ( boy was I wrong ).  <img /> tags cannot have the border attribute.  No Problem!

The Fix
Go into the article editor.  Click on the offending image and set border to .... nothing.  Click update and done and done.

Of course toggle the editor to html mode just to confirm and ............... the border = 0 is back.  What?!?!?

The next Fix
Ok not a problem.  I'll just remove it here in the html and update.  Problem solved.  But .... I should check just in case.  What?!?!?!? It's back!  But!!! How?!?! Where?!?! AAAAAAAAAARGGGGGGG!!!!!!

At this point I'm about to declare that we cannot be strict compliant using Joomla when I finally discover the answer to life ....... I mean the answer to my problem.

The actual Fix
In plugins/editors/tinymce.php on line 353 is the valid elements control for the img tag.  On this line exists border=0 which means if border is missing add it with a value of 0.  So, I removed it.  And all is right in the world.

So to change what attributes tinymce forces, adds, or to change the default value. The file to change is plugins/editors/tinymce.php.

Good Luck and Good Night!

No comments: