Prestashop has an issue with adding YouTube videos to various places where you need it.
We first encountered this issue on our own projects, but it’s also mentioned on the Prestashop forum – so here’s the solution to this trouble:
Comment the following lines in the class Validate (classes/Validate.php) of the method isCleanHtml:
1 2 |
if (!$allow_iframe && preg_match('/<[\s]*(i?frame|form|input|embed|object)/ims', $html)) return false; |
So the method should look as follows:
Partner With Us
Let's discuss how to grow your business. Get a Free Quote.
Talk to Andrey
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
if (!$allow_iframe && preg_match('/<[\s]*(i?frame|form|input|embed|object)/ims', $html)) return false; so the method should look as follows: public static function isCleanHtml($html, $allow_iframe = false) { $events = 'onmousedown|onmousemove|onmmouseup|onmouseover|onmouseout|onload|onunload|onfocus|onblur|onchange'; $events .= '|onsubmit|ondblclick|onclick|onkeydown|onkeyup|onkeypress|onmouseenter|onmouseleave|onerror|onselect|onreset|onabort|ondragdrop|onresize|onactivate|onafterprint|onmoveend'; $events .= '|onafterupdate|onbeforeactivate|onbeforecopy|onbeforecut|onbeforedeactivate|onbeforeeditfocus|onbeforepaste|onbeforeprint|onbeforeunload|onbeforeupdate|onmove'; $events .= '|onbounce|oncellchange|oncontextmenu|oncontrolselect|oncopy|oncut|ondataavailable|ondatasetchanged|ondatasetcomplete|ondeactivate|ondrag|ondragend|ondragenter|onmousewheel'; $events .= '|ondragleave|ondragover|ondragstart|ondrop|onerrorupdate|onfilterchange|onfinish|onfocusin|onfocusout|onhashchange|onhelp|oninput|onlosecapture|onmessage|onmouseup|onmovestart'; $events .= '|onoffline|ononline|onpaste|onpropertychange|onreadystatechange|onresizeend|onresizestart|onrowenter|onrowexit|onrowsdelete|onrowsinserted|onscroll|onsearch|onselectionchange'; $events .= '|onselectstart|onstart|onstop'; if (preg_match('/<[\s]*script/ims', $html) || preg_match('/('.$events.')[\s]*=/ims', $html) || preg_match('/.*script\:/ims', $html)) return false; //if (!$allow_iframe && preg_match('/<[\s]*(i?frame|form|input|embed|object)/ims', $html)) //return false; return true; } |
The admin panel will display it as question, but this is because the editor does not load the object, but it will be ok on the frontend.
Partner With Us
Looking for a partner to grow your business? We are the right company to bring your webstore to success.
Talk to Andrey
Thank you soo much. it Works!!!
@Silvia you can contact our support team via [email protected] for help
Hi,
I’m trying to insert a YouTube video using a built-in code on a CMS page, but when I try to save the code the save button does not work. I’ve already enabled iframe and I’ve already tested everything I’ve been told in other forums.
I needed help.
Version prestashop 1.7.
Thank you.
@Krystian : Thank you !
@ Denis Urevich : Please update your post with Krystian’s solution. Core files modifications usually disappear while updating…
Oh, you need only to enable iframes in Preferences -> General, there is no need to do this modification.
Thanks ;)
Oh, you need only to enable iframes in Preferences -> General, there is no need to do this modification.