Exercise / HTMLPurifierBundle

HTML Purifier is a standards-compliant HTML filter library written in PHP.
http://htmlpurifier.org/
Other
275 stars 56 forks source link

how to add custom attribute to whitelist by edit config.yml #26

Closed jamesBan closed 4 years ago

jamesBan commented 9 years ago

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 7 years ago

I would like to do the same. Has anyone found out how to do it?

zalexki commented 7 years ago

Still trying to find/understand this feature if anyone has a solution or a newer bundle that does the trick. :)

HeahDude commented 6 years ago

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!

HeahDude commented 4 years ago

52 has been merged and 3.0 is out as beta. Closing here, please open an issue if there is any bug with this feature (see the updated README and CHANGELOG files).