ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
HTMLPurifier_AttrTransform_ImgRequired Class Reference

Transform that supplies default values for the src and alt attributes in img tags, as well as prevents the img tag from being removed because of a missing alt tag. More...

+ Inheritance diagram for HTMLPurifier_AttrTransform_ImgRequired:
+ Collaboration diagram for HTMLPurifier_AttrTransform_ImgRequired:

Public Member Functions

 transform ($attr, $config, $context)
- Public Member Functions inherited from HTMLPurifier_AttrTransform
 prependCSS (&$attr, $css)
 Prepends CSS properties to the style attribute, creating the attribute if it doesn't exist.
 confiscateAttr (&$attr, $key)
 Retrieves and removes an attribute.

Detailed Description

Transform that supplies default values for the src and alt attributes in img tags, as well as prevents the img tag from being removed because of a missing alt tag.

This needs to be registered as both a pre and post attribute transform.

Definition at line 11 of file ImgRequired.php.

Member Function Documentation

HTMLPurifier_AttrTransform_ImgRequired::transform (   $attr,
  $config,
  $context 
)
Parameters
array$attr
HTMLPurifier_Config$config
HTMLPurifier_Context$context
Returns
array

Reimplemented from HTMLPurifier_AttrTransform.

Definition at line 20 of file ImgRequired.php.

{
$src = true;
if (!isset($attr['src'])) {
if ($config->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;
}

The documentation for this class was generated from the following file: