3 require_once 'HTMLPurifier/AttrTransform.php';
6 * Class for handling width/height length attribute transformations to CSS
8 class HTMLPurifier_AttrTransform_Length
extends HTMLPurifier_AttrTransform
14 public function __construct($name, $css_name = null) {
16 $this->cssName
= $css_name ?
$css_name : $name;
19 public function transform($attr, $config, $context) {
20 if (!isset($attr[$this->name
])) return $attr;
21 $length = $this->confiscateAttr($attr, $this->name
);
22 if(ctype_digit($length)) $length .= 'px';
23 $this->prependCSS($attr, $this->cssName
. ":$length;");