Welcome! » Log In » Create A New Profile

Use HTMLPurifier to filter out everything but instagrm embed code

Posted by Sophie 
Use HTMLPurifier to filter out everything but instagrm embed code
April 11, 2017 06:06AM

I am searching for a long time on net. But no use. Please help or try to give some ideas how to achieve this.

I used HTMLPurifier in Laravel. I have been trying to configure HTMLPurifier to accept instagram embed code.

HTMLPurifier setting

return [ 'encoding' => 'UTF-8', 'finalize' => true, 'cachePath' => storage_path('app/purifier'), 'cacheFileMode' => 0755, 'settings' => [ 'default' => [ 'HTML.Doctype' => 'XHTML 1.0 Transitional', 'HTML.Allowed' => 'div,b,strong,p,i,em,blockquote[class|style],a[href|title],ul,ol,li,p[style],br,span[style],img[width|alt|src],iframe[src|width|height|class|frameborder]', 'CSS.AllowedProperties' => 'font,font-size,font-weight,font-style,font-family,text-decoration,padding-left,color,background-color,text-align', 'HTML.AllowedAttributes' => 'style,src', 'AutoFormat.AutoParagraph' => true, 'AutoFormat.RemoveEmpty' => true, "HTML.SafeIframe" => true, "URI.SafeIframeRegexp" => "%^(http://|https://|//)(www.youtube.com/embed/|player.vimeo.com/video/|api.soundcloud.com/tracks/)%", ], 'test' => [ 'Attr.EnableID' => true ] ],

After I using clean function on Instagram code,some of value of style attribute will be filter out. I have been trying to allow "style" in 'HTML.AllowedAttributes' setting.But it was not working.And tried to allowed css properties-'box-shadow'...etc,but some properties was not supported.

I want to keep all value of style attribute, and add some data attribute in HTMLPurifier.What can I do?

Thanks for your help !!

Re: Use HTMLPurifier to filter out everything but instagrm embed code
April 11, 2017 02:03PM

Maybe you can adapt the instructions at http://htmlpurifier.org/docs/enduser-youtube.html to apply to Instagram.

Sorry, you do not have permission to post/reply in this forum.