[3.1.1] Disable percent height/width attributes for img
[htmlpurifier/bfroehle.git] / library / HTMLPurifier / HTMLModule / Image.php
blob5a7afe62a59c0195223c96a483842b6e990506fb
1 <?php
3 /**
4 * XHTML 1.1 Image Module provides basic image embedding.
5 * @note There is specialized code for removing empty images in
6 * HTMLPurifier_Strategy_RemoveForeignElements
7 */
8 class HTMLPurifier_HTMLModule_Image extends HTMLPurifier_HTMLModule
11 public $name = 'Image';
13 public function __construct() {
14 $img = $this->addElement(
15 'img', 'Inline', 'Empty', 'Common',
16 array(
17 'alt*' => 'Text',
18 // According to the spec, it's Length, but percents can
19 // be abused, so we allow only Pixels. A trusted module
20 // could overload this with the real value.
21 'height' => 'Pixels',
22 'width' => 'Pixels',
23 'longdesc' => 'URI',
24 'src*' => new HTMLPurifier_AttrDef_URI(true), // embedded
27 // kind of strange, but splitting things up would be inefficient
28 $img->attr_transform_pre[] =
29 $img->attr_transform_post[] =
30 new HTMLPurifier_AttrTransform_ImgRequired();