Youtube oembed & plugin fix

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Youtube oembed & plugin fix

Fabrizio Gargano
Hi everybody.
It seems oembed result for playlists is a bit incorrect.


The oembed url for xml format is:

The html tag, imho, should have a src attribute for iframe like

Youtube's iframe src lacks the index parameter, so the embed starts to
play from the first video.

So I wrote a simple mu-plugins to append it to html results:

function fix_iframe_src($html, $url){
    if(strpos($url,"")!==false &&
strpos($url,"list=")!==false && strpos($html,"index=")===false){
      foreach(explode("&",$url) as $param){
           return preg_replace('/(src="[^"]+)/',"\\1&index=$index",$html);
    return $html;

wp-hackers mailing list
[hidden email]