AcidLava Posted Wednesday at 09:13 AM Share Posted Wednesday at 09:13 AM (edited) Hello, On Prestashop 8.2.3, when I add something like loading="lazy" in the source code of an element via the text editor, it disappears as soon as I save (because of HTML Purifier?)? This is quite problematic, since even when writing a blog post, the code gets completely altered at the slightest mistake. What's the cleanest solution to work around this issue? Thank you. Edited Wednesday at 11:15 AM by AcidLava (see edit history) Link to comment Share on other sites More sharing options...
ecomsoft Posted Wednesday at 11:50 AM Share Posted Wednesday at 11:50 AM (edited) are you talking about the product descriptions or somewhere else Edited Wednesday at 11:50 AM by ecomsoft (see edit history) Link to comment Share on other sites More sharing options...
AcidLava Posted Wednesday at 12:07 PM Author Share Posted Wednesday at 12:07 PM @ecomsoft everywhere the native html editor is involved (product descriptions included) Link to comment Share on other sites More sharing options...
alex_developer Posted Wednesday at 12:14 PM Share Posted Wednesday at 12:14 PM 3 hours ago, AcidLava said: What's the cleanest solution to work around this issue? As an option, add an attribute to the HTML Purifier configuration PrestaShop allows you to extend the list of allowed attributes in HTMLPurifier_Config. This is done by overriding TinyMCE / CMS Controller, for example in a module or override. Link to comment Share on other sites More sharing options...
AcidLava Posted Wednesday at 12:39 PM Author Share Posted Wednesday at 12:39 PM (edited) I tried this via Tools.php but it doesn't work. <?php class ToolsOverride extends Tools { public static function purify($html, $uri_unescape = false) { static $purifier = null; if (!$purifier) { require_once _PS_TOOL_DIR_.'htmlpurifier/HTMLPurifier.standalone.php'; $config = HTMLPurifier_Config::createDefault(); // Ajout de l’attribut "loading" pour les balises <img> $def = $config->getHTMLDefinition(true); if ($def) { $def->addAttribute('img', 'loading', 'Enum#lazy,eager,auto'); } $purifier = new HTMLPurifier($config); } return $purifier->purify($html); } } Edited Wednesday at 12:44 PM by AcidLava (see edit history) Link to comment Share on other sites More sharing options...
alex_developer Posted Wednesday at 04:36 PM Share Posted Wednesday at 04:36 PM (edited) 3 hours ago, AcidLava said: I tried this via Tools.php but it doesn't work. Ovveridethe purifyHTML method in Tools. Add attributes to an existing tag: $def->addAttribute(‘a’, ‘data-locale’, ‘Text’); Add a new tag: $def->addElement(‘canvas’, ‘Block’, ‘Flow’, ‘Common’, [‘data-url’ => ‘URI’]); Edited Wednesday at 04:39 PM by Oleksandr (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now