File indexing completed on 2025-01-26 05:29:07
0001 <?php 0002 0003 /** 0004 * XHTML 1.1 Image Module provides basic image embedding. 0005 * @note There is specialized code for removing empty images in 0006 * HTMLPurifier_Strategy_RemoveForeignElements 0007 */ 0008 class HTMLPurifier_HTMLModule_Image extends HTMLPurifier_HTMLModule 0009 { 0010 0011 /** 0012 * @type string 0013 */ 0014 public $name = 'Image'; 0015 0016 /** 0017 * @param HTMLPurifier_Config $config 0018 */ 0019 public function setup($config) 0020 { 0021 $max = $config->get('HTML.MaxImgLength'); 0022 $img = $this->addElement( 0023 'img', 0024 'Inline', 0025 'Empty', 0026 'Common', 0027 array( 0028 'alt*' => 'Text', 0029 // According to the spec, it's Length, but percents can 0030 // be abused, so we allow only Pixels. 0031 'height' => 'Pixels#' . $max, 0032 'width' => 'Pixels#' . $max, 0033 'longdesc' => 'URI', 0034 'src*' => new HTMLPurifier_AttrDef_URI(true), // embedded 0035 ) 0036 ); 0037 if ($max === null || $config->get('HTML.Trusted')) { 0038 $img->attr['height'] = 0039 $img->attr['width'] = 'Length'; 0040 } 0041 0042 // kind of strange, but splitting things up would be inefficient 0043 $img->attr_transform_pre[] = 0044 $img->attr_transform_post[] = 0045 new HTMLPurifier_AttrTransform_ImgRequired(); 0046 } 0047 } 0048 0049 // vim: et sw=4 sts=4