PageRenderTime 25ms CodeModel.GetById 1ms RepoModel.GetById 0ms app.codeStats 0ms

/plugins/vjCommentPlugin/lib/tools/htmlpurifier/library/HTMLPurifier/HTMLModule/Image.php

https://bitbucket.org/Kudlaty/360kdw
PHP | 40 lines | 25 code | 6 blank | 9 comment | 2 complexity | 911df038afaefbc0f662a3d6fa8d9554 MD5 | raw file
Possible License(s): LGPL-2.1
  1. <?php
  2. /**
  3. * XHTML 1.1 Image Module provides basic image embedding.
  4. * @note There is specialized code for removing empty images in
  5. * HTMLPurifier_Strategy_RemoveForeignElements
  6. */
  7. class HTMLPurifier_HTMLModule_Image extends HTMLPurifier_HTMLModule
  8. {
  9. public $name = 'Image';
  10. public function setup($config) {
  11. $max = $config->get('HTML.MaxImgLength');
  12. $img = $this->addElement(
  13. 'img', 'Inline', 'Empty', 'Common',
  14. array(
  15. 'alt*' => 'Text',
  16. // According to the spec, it's Length, but percents can
  17. // be abused, so we allow only Pixels.
  18. 'height' => 'Pixels#' . $max,
  19. 'width' => 'Pixels#' . $max,
  20. 'longdesc' => 'URI',
  21. 'src*' => new HTMLPurifier_AttrDef_URI(true), // embedded
  22. )
  23. );
  24. if ($max === null || $config->get('HTML.Trusted')) {
  25. $img->attr['height'] =
  26. $img->attr['width'] = 'Length';
  27. }
  28. // kind of strange, but splitting things up would be inefficient
  29. $img->attr_transform_pre[] =
  30. $img->attr_transform_post[] =
  31. new HTMLPurifier_AttrTransform_ImgRequired();
  32. }
  33. }
  34. // vim: et sw=4 sts=4