HTMLPurifier 4.4.0
/home/ezyang/Dev/htmlpurifier/library/HTMLPurifier/HTMLModule/Image.php
Go to the documentation of this file.
00001 <?php
00002 
00008 class HTMLPurifier_HTMLModule_Image extends HTMLPurifier_HTMLModule
00009 {
00010 
00011     public $name = 'Image';
00012 
00013     public function setup($config) {
00014         $max = $config->get('HTML.MaxImgLength');
00015         $img = $this->addElement(
00016             'img', 'Inline', 'Empty', 'Common',
00017             array(
00018                 'alt*' => 'Text',
00019                 // According to the spec, it's Length, but percents can
00020                 // be abused, so we allow only Pixels.
00021                 'height' => 'Pixels#' . $max,
00022                 'width'  => 'Pixels#' . $max,
00023                 'longdesc' => 'URI',
00024                 'src*' => new HTMLPurifier_AttrDef_URI(true), // embedded
00025             )
00026         );
00027         if ($max === null || $config->get('HTML.Trusted')) {
00028             $img->attr['height'] =
00029             $img->attr['width'] = 'Length';
00030         }
00031 
00032         // kind of strange, but splitting things up would be inefficient
00033         $img->attr_transform_pre[] =
00034         $img->attr_transform_post[] =
00035             new HTMLPurifier_AttrTransform_ImgRequired();
00036     }
00037 
00038 }
00039 
00040 // vim: et sw=4 sts=4