how to add custom attribute to whitelist by edit config.yml
jamesBan opened this issue ยท 4 comments
jamesBan commented
I use this bundle in my project, i want to konw how to setting config.yml.
this is the raw HTMLPurifier code.
<?php
$dirty_html = <<<EOF
<img src="/my.jpg" data-type="5" alt="" data-image-size="100,200" />
EOF;
$config = HTMLPurifier_Config::createDefault();
$def = $config->getHTMLDefinition(true);
$def->addAttribute('img', 'data-type', 'Text');
$def->addAttribute('img', 'data-image-size', 'Text');
$purifier = new HTMLPurifier($config);
VyctoryaStar commented
I would like to do the same. Has anyone found out how to do it?
zalexki commented
Still trying to find/understand this feature if anyone has a solution or a newer bundle that does the trick. :)
HeahDude commented
See https://github.com/heahprod/HTMLPurifierBundle/pull/2 that will hopefully be merged in #46.
Feel free to test the branch, I've tested it in a project of mine and it worked pretty well so far. It would be nice if you could report any issue. Thanks!