Skip to content

Support <video> tags #34

@sdespont

Description

@sdespont

I adapted the code some times ago to accept the "< video >" tags, but it is not working anymore since versions 0.2.X and I really don't know why. The "< video >" tag is still present after purrifying, but the "src" element is removed.

Any hints to figure this out?

use Symfony\Component\Form\DataTransformerInterface;

class HTMLPurifierTransformer implements DataTransformerInterface
{
    private $purifier;

    /**
     * Constructor.
     *
     * @param \HTMLPurifier $purifier
     */
    public function __construct()
    {
          //Find full HTML5 config : https://github.com/kennberg/php-htmlpurfier-html5
          $config = \HTMLPurifier_Config::createDefault();
          $config->set('HTML.Doctype', 'HTML 4.01 Transitional');
          $config->set('HTML.SafeIframe', true);

          // Set some HTML5 properties
          $config->set('HTML.DefinitionID', 'html5-definitions'); // unqiue id
          $config->set('HTML.DefinitionRev', 1);
          if ($def = $config->maybeGetRawHTMLDefinition()) {
            // http://developers.whatwg.org/the-video-element.html#the-video-element
            $def->addElement('video', 'Block', 'Optional: (source, Flow) | (Flow, source) | Flow', 'Common', array(
              'src' => 'URI',
              'type' => 'Text',
              'width' => 'Length',
              'height' => 'Length',
              'poster' => 'URI',
              'preload' => 'Enum#auto,metadata,none',
              'controls' => 'Bool',
            ));
          }
          $this->purifier = new \HTMLPurifier($config);
    }
           ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions