Easy! Reader


Monday, September 21, 2009

Getting TinyMCE to respect empty alt attributes

This one took a little futzing around and digging through the TinyMCE forum to figure out, but it's been nagging at me for a while. By default (or at least in the default configuration provided under the LG TinyMCE extension for ExpressionEngine), TinyMCE will remove the alt attribute if it is empty. Obviously, for accessibility and validation reasons, this is highly undesirable and needs correcting. Thankfully, the fix is pretty simple: add the following to your TinyMCE configuration options:

// fix empty alt attributes
extended_valid_elements : 'img[src|alt=|title|class|id|style|height|width]',
verify_html : true,
view raw gistfile1.js This Gist brought to you by GitHub.

I choose to add these options right after declaring my cleanup/output options but before the remainder of the configuration. If you choose to tack these options on at the end, just remember to remove the trailing comma.

Posted by Aaron Gustafson in • design & developmentprogrammingweb standards
Permalink
Next entry: A new "onload" scheme Previous entry: RIP XHTML 2
kolchakA  on  2009-11-30  at  10:01 AM

Actually i don’t like using TinyMCE, because it’s often just corrupts the page layout.

Jessica  on  2009-12-15  at  09:57 PM

Oh, wow!  Thanks for posting this!  Such an easy fix.

.(JavaScript must be enabled to view this email address)  on  2010-01-06  at  01:11 AM

I used to write for The Fritz (about a million years ago at this point?) and was wondering how you were doing and if the magazine was in archives online anywhere. Drop me a line if you get a chance; I hope you’re doing well. Thanks for setting up my first interview ever (with Gen).

Rapid Share  on  2010-02-20  at  04:18 AM

right, the fix is pretty simple, still I want to thank you, cause it could have caused me much trouble (not much aware of TinyMCE and all this stuff). you don’t always meet people who take care and time to inform users about such trifles. but it means much;)

Page 1 of 1 pages

Post a comment

Commenting is not available in this section entry.