2007-02-04 16:35:40 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* XHTML 1.1 Image Module provides basic image embedding.
|
2007-02-04 20:09:35 +00:00
|
|
|
* @note There is specialized code for removing empty images in
|
|
|
|
* HTMLPurifier_Strategy_RemoveForeignElements
|
2007-02-04 16:35:40 +00:00
|
|
|
*/
|
|
|
|
class HTMLPurifier_HTMLModule_Image extends HTMLPurifier_HTMLModule
|
|
|
|
{
|
|
|
|
|
2007-11-25 02:24:39 +00:00
|
|
|
public $name = 'Image';
|
2007-02-04 16:35:40 +00:00
|
|
|
|
2008-05-22 19:36:59 +00:00
|
|
|
public function setup($config) {
|
2008-05-23 02:09:43 +00:00
|
|
|
$max = $config->get('HTML', 'MaxImgLength');
|
2008-04-23 02:40:17 +00:00
|
|
|
$img = $this->addElement(
|
2008-04-21 23:28:52 +00:00
|
|
|
'img', 'Inline', 'Empty', 'Common',
|
2007-05-09 22:01:07 +00:00
|
|
|
array(
|
2007-06-20 21:39:28 +00:00
|
|
|
'alt*' => 'Text',
|
2008-05-21 02:01:25 +00:00
|
|
|
// According to the spec, it's Length, but percents can
|
2008-05-23 02:09:43 +00:00
|
|
|
// be abused, so we allow only Pixels.
|
|
|
|
'height' => 'Pixels#' . $max,
|
|
|
|
'width' => 'Pixels#' . $max,
|
2007-05-09 22:01:07 +00:00
|
|
|
'longdesc' => 'URI',
|
2007-06-20 21:39:28 +00:00
|
|
|
'src*' => new HTMLPurifier_AttrDef_URI(true), // embedded
|
2007-05-09 22:01:07 +00:00
|
|
|
)
|
2007-02-04 16:35:40 +00:00
|
|
|
);
|
2008-05-23 02:09:43 +00:00
|
|
|
if ($max === null || $config->get('HTML', 'Trusted')) {
|
|
|
|
$img->attr['height'] =
|
|
|
|
$img->attr['width'] = 'Length';
|
|
|
|
}
|
|
|
|
|
2007-06-20 21:39:28 +00:00
|
|
|
// kind of strange, but splitting things up would be inefficient
|
|
|
|
$img->attr_transform_pre[] =
|
2007-05-12 20:44:47 +00:00
|
|
|
$img->attr_transform_post[] =
|
2007-02-04 16:35:40 +00:00
|
|
|
new HTMLPurifier_AttrTransform_ImgRequired();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|