Search code examples
phpencodinghtmlpurifier

HTMLPurifier Youtube


<?php

require_once '/library/HTMLPurifier/HTMLPurifier.auto.php';

    $config = HTMLPurifier_Config::createDefault();

    $config->set('Filter.YouTube', true);

        $purifier = new HTMLPurifier($config);
?>

(^ This is my only settings for HTMLPurifier)

It should <span class="youtube-embed">nto6EvPFO0Q</span> make this in to a Youtube embbeded video. But it's not working. (Nothing happens simply)

But loading like this works:

<object width="425" height="350">
  <param name="movie" value="http://www.youtube.com/v/nto6EvPFO0Q />
  <param name="wmode" value="transparent" />
  <embed src="http://www.youtube.com/v/nto6EvPFO0Q"
         type="application/x-shockwave-flash"
         wmode="transparent" width="425" height="350" />
</object>

(Is this a security issue? ^)


Solution

  • Use UTF-8. All other character sets are obsolete and should never be used except in legacy applications where you have no other choice.

    Edit (after update of question):

    First, you should use this:

    <iframe class="youtube-player" type="text/html" width="640" height="385"
     src="http://www.youtube.com/embed/XXXXIDXXXX" frameborder="0"></iframe>
    

    Instead since it works on smart phones and the flash version doesn't.

    Second, according to their documentation you need to download and include YouTube.php from http://repo.or.cz/w/htmlpurifier.git?a=blob;hb=HEAD;f=library/HTMLPurifier/Filter/YouTube.php (and when you do so update it to the new type of embed code).