Background.php 524 B

1234567891011121314151617181920212223
  1. <?php
  2. /**
  3. * Pre-transform that changes proprietary background attribute to CSS.
  4. */
  5. class HTMLPurifier_AttrTransform_Background extends HTMLPurifier_AttrTransform {
  6. public function transform($attr, $config, $context) {
  7. if (!isset($attr['background'])) return $attr;
  8. $background = $this->confiscateAttr($attr, 'background');
  9. // some validation should happen here
  10. $this->prependCSS($attr, "background-image:url($background);");
  11. return $attr;
  12. }
  13. }
  14. // vim: et sw=4 sts=4