From ffb1997902facb36b78a7cfa522f41f2b3d71cda Mon Sep 17 00:00:00 2001 From: Mike Macgirvin Date: Wed, 8 Sep 2010 20:14:17 -0700 Subject: mistpark 2.0 infrasturcture lands --- library/HTMLPurifier/AttrTransform/ImgRequired.php | 43 ++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 library/HTMLPurifier/AttrTransform/ImgRequired.php (limited to 'library/HTMLPurifier/AttrTransform/ImgRequired.php') diff --git a/library/HTMLPurifier/AttrTransform/ImgRequired.php b/library/HTMLPurifier/AttrTransform/ImgRequired.php new file mode 100644 index 000000000..7f0e4b7a5 --- /dev/null +++ b/library/HTMLPurifier/AttrTransform/ImgRequired.php @@ -0,0 +1,43 @@ +get('Core.RemoveInvalidImg')) return $attr; + $attr['src'] = $config->get('Attr.DefaultInvalidImage'); + $src = false; + } + + if (!isset($attr['alt'])) { + if ($src) { + $alt = $config->get('Attr.DefaultImageAlt'); + if ($alt === null) { + // truncate if the alt is too long + $attr['alt'] = substr(basename($attr['src']),0,40); + } else { + $attr['alt'] = $alt; + } + } else { + $attr['alt'] = $config->get('Attr.DefaultInvalidImageAlt'); + } + } + + return $attr; + + } + +} + +// vim: et sw=4 sts=4 -- cgit v1.2.3