Welcome! » Log In » Create A New Profile

[ImplementedFeature] how do you allow image border attribute

Posted by agip33 
[ImplementedFeature] how do you allow image border attribute
March 29, 2007 01:29AM

<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='<a href="anyurl.html"><img src="anyimage.gif" border="0"></a>';

When you run it, the output becomes something like this:

$cleanhtml='<a href="anyurl.html"><img src="anyimage.gif" alt="anyimage.gif" /></a>';

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->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

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

Support for this has been committed to the trunk and will be shipped with 1.6.

HTML Purifier, Standards Compliant HTML Filtering

Author:
Your Email:

Subject:

HTML input is enabled. Make sure you escape all HTML and angled brackets with < and >.

Auto-paragraphing is enabled. Double newlines will be converted to paragraphs; for single newlines, use the pre tag.

Allowed tags: a, abbr, acronym, b, blockquote, caption, cite, code, dd, del, dfn, div, dl, dt, em, i, ins, kbd, li, ol, p, pre, s, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, var.

For inputting literal code such as HTML and PHP for display, use CDATA tags to auto-escape your angled brackets, and pre to preserve newlines:

<pre><![CDATA[
Place code here
]]></pre>

Power users, you can hide this notice with:

.htmlpurifier-help {display:none;}

Message: