|
[ImplementedFeature] how do you allow image border attribute March 29, 2007 01:29AM |
Registered: 6 years ago Posts: 1 |
<strong>Editorial note:</strong> The border attribute in img tag in natively supported 1.6.0 and later. -- Ed
I'm having a little trouble with allowing img tags with border attribute. I like the default settings, but I just want to allow this attribute.
$dirtyhtml='&lt;a href="anyurl.html"&gt;&lt;img src="anyimage.gif" border="0"&gt;&lt;/a&gt;';
When you run it, the output becomes something like this:
$cleanhtml='&lt;a href="anyurl.html"&gt;&lt;img src="anyimage.gif" alt="anyimage.gif" /&gt;&lt;/a&gt;';
The border within img tag is removed. I want this system to allow border=0 in image tags.
How would I begin to set that up? I tried something like this: $config-&gt;set('HTML', 'AllowedAttributes', 'a.style,a.href,a.title,img.border,img.src,img.alt,*.class,*.style'); But that doesn't seem to work.
Help please! :) Thank you!
Edited 4 time(s). Last edit at 04/28/2007 10:38AM by Ambush Commander.
|
Re: how do you allow image border attribute March 29, 2007 04:25PM |
Admin Registered: 6 years ago Posts: 2,636 |
Border is not yet part of the default filterset, as it is a deprecated feature. I plan on adding it in a future release soon, but in the meantime, you can implement it yourself by doing:
$def =& $config->getHTMLDefinition(); $def->info['img']->attr['border'] = new HTMLPurifier_AttrDef_HTML_Pixels();
(warning, untested)
HTML Purifier, Standards Compliant HTML Filtering
Edited 1 time(s). Last edit at 03/29/2007 01:25PM by Ambush Commander.
|
Re: how do you allow image border attribute March 29, 2007 07:56PM |
Admin Registered: 6 years ago Posts: 2,636 |
Support for this has been committed to the trunk and will be shipped with 1.6.
HTML Purifier, Standards Compliant HTML Filtering