WP YouTube Lyte - Version 1.1.8

Version Description

  • bugfix: playlists API changed: playlists can now have ID's of more than 16 chars and always should be prepended with PL, which broke playlist rendering. Hat tip for the guys over at dubtechnoblog.com for reporting!
  • bugfix: further work on excerpts to make sure http(v|a) links in manual excerpts get replaced by a lyte player.
Download this release

Release Info

Developer futtta
Plugin Icon 128x128 WP YouTube Lyte
Version 1.1.8
Comparing to
See all releases

Code changes from version 1.1.7 to 1.1.8

Files changed (4) hide show
  1. lyte/lyte-min.js +1 -1
  2. lyte/lyte.js +2 -2
  3. readme.txt +6 -2
  4. wp-youtube-lyte.php +8 -7
lyte/lyte-min.js CHANGED
@@ -1 +1 @@
1
- (function(a){function e(a){qsa="";if(rqs=a.className.match(/qsa_(.*)\s/,"$1"))qsa=rqs[1].replace(/\\([\&\=\?])/g,"$1");return qsa}function f(a,b){p=d.getElementById(a);c=d.createElement("div");c.className="tC";t=d.createElement("div");t.className="tT";c.appendChild(t);t.innerHTML=b;p.appendChild(c)}function g(a,b){if(typeof a.setAttribute==="function")a.setAttribute("style",b);else if(typeof a.style.setAttribute==="object")a.style.setAttribute("cssText",b)}function h(a){scr=d.createElement("script");scr.src=a;scr.type="text/javascript";d.getElementsByTagName("head")[0].appendChild(scr)}function i(a,b,c){if(d.getElementsByClassName){i=function(a,b,c){c=c||d;var e=c.getElementsByClassName(a),f=b?new RegExp("\\b"+b+"\\b","i"):null,g=[],h;for(var i=0,j=e.length;i<j;i+=1){h=e[i];if(!f||f.test(h.nodeName)){g.push(h)}}return g}}else if(d.evaluate){i=function(a,b,c){b=b||"*";c=c||d;var e=a.split(" "),f="",g="http://www.w3.org/1999/xhtml",h=d.documentElement.namespaceURI===g?g:null,i=[],j,k;for(var l=0,m=e.length;l<m;l+=1){f+="[contains(concat(' ', @class, ' '), ' "+e[l]+" ')]"}try{j=d.evaluate(".//"+b+f,c,h,0,null)}catch(n){j=d.evaluate(".//"+b+f,c,null,0,null)}while(k=j.iterateNext()){i.push(k)}return i}}else{i=function(a,b,c){b=b||"*";c=c||d;var e=a.split(" "),f=[],g=b==="*"&&c.all?c.all:c.getElementsByTagName(b),h,i=[],j;for(var k=0,l=e.length;k<l;k+=1){f.push(new RegExp("(^|\\s)"+e[k]+"(\\s|$)"))}for(var m=0,n=g.length;m<n;m+=1){h=g[m];j=false;for(var o=0,p=f.length;o<p;o+=1){j=f[o].test(h.className);if(!j){break}}if(j){i.push(h)}}return i}}return i(a,b,c)}d=document;var b="http";if(bU.indexOf("https")!=-1){b+="s"}a.te=function(){if(!c){var c=1;var f=navigator.userAgent.match(/(iphone|ipad|ipod)/i);lts=i("lyMe","div");for(var j=0,k=lts.length;j<k;j+=1){p=lts[j];vid=p.id.substring(4);cN=p.className.replace(/lyMe/,"lyte")+" lP";p.className=cN;pl=d.createElement("div");pl.id="lyte_"+vid;pl.className="pL";if(f===null){p.onclick=a.play;pW=p.style.width.match(/\d+/g)[0];pH=p.style.height.match(/\d+/g)[0];bgA="-60px";if(cN.indexOf("widget")!==-1||pW/pH<1.7)bgA="-10px";qsa=e(p);cImg='<img src="'+bU+"controls-"+pW+'.png" height="40px" width="'+pW+'px" class="ctrl" alt=""/>';pImg='<img src="'+bU+'play.png" width="83px" height="55px" alt="Click to play" style="margin-top:'+(pH/2-30)+'px;opacity:0.7;" onmouseover="this.style.opacity=1;" onmouseout="this.style.opacity=0.8;"/>';ytA="://gdata.youtube.com/feeds/api/";if(cN.indexOf("audio")!==-1){g(pl,"height:"+pH+"px;width:"+pW+"px;");pl.innerHTML=cImg}else if(cN.indexOf("playlist")!==-1){g(pl,"height:"+pH+"px;width:"+pW+"px;");pl.innerHTML=pImg+cImg;joU=b+ytA+"playlists/"+vid+"?v=2&alt=json-in-script&callback=ly.prsPL&fields=id,title,entry";h(joU)}else{g(pl,"height:"+pH+"px;width:"+pW+"px;background:url('"+b+"://img.youtube.com/vi/"+vid+"/0.jpg') no-repeat scroll center "+bgA+" rgb(0, 0, 0);background-size:cover;");pl.innerHTML=pImg+cImg;if(cN.indexOf("widget")===-1&&qsa.indexOf("showinfo=0")===-1){joU=b+ytA+"videos/"+vid+"?fields=id,title&alt=json-in-script&callback=ly.prsV";h(joU)}}p.appendChild(pl)}else{a.play(p.id)}}}var c=""};a.play=function(a){if(typeof a==="string"){tH=d.getElementById(a);aP=0}else{tH=this;tH.onclick="";aP=1}vid=tH.id.substring(4);hidef=0;if(tH.className.indexOf("hidef")!==-1){hidef=1}if(tH.className.indexOf("playlist")===-1){eU=b+"://www.youtube.com/embed/"+vid+"?"}else{eU=b+"://www.youtube.com/embed/videoseries?list=PL"+vid+"&"}qsa=e(tH);if(tH.className.indexOf("audio")!==-1){qsa+="&autohide=0";aHgh="438";aSt="position:relative;top:-400px;"}else{aHgh=tH.clientHeight;aSt=""}tH.innerHTML='<iframe id="iF_'+vid+'" width="'+tH.clientWidth+'px" height="'+aHgh+'px" src="'+eU+"autoplay="+aP+"&wmode=opaque&rel=0&egm=0&iv_load_policy=3&hd="+hidef+qsa+'" frameborder="0" style="'+aSt+'"></iframe>';if(typeof tH.firstChild.getAttribute("kabl")=="string")tH.innerHTML="Please check Karma Blocker's config."};a.prsV=function(a){tI=a.entry.title.$t;idu=a.entry.id.$t;id="lyte_"+idu.substring(idu.length-11);f(id,tI)};a.prsPL=function(a){thumb=a.feed.entry[0].media$group.media$thumbnail[1].url;idu=a.feed.id.$t;id="lyte_"+idu.substring(idu.length-16);title="Playlist: "+a.feed.title.$t;pl=d.getElementById(id);pH=pl.style.height;pW=pl.style.width;if(b=="https"&&thumb.indexOf("https"==-1)){thumb=thumb.replace("http://","https://")}g(pl,"height:"+pH+";width:"+pW+";background:url('"+thumb+"') no-repeat scroll center -50px rgb(0, 0, 0); background-size:cover;");f(id,title)};})(window.ly=window.ly||{});(function(){var a=window;var b=document;if(a.addEventListener){a.addEventListener("load",ly.te,false);b.addEventListener("DomContentLoaded",function(){setTimeout("ly.te()",750)},false)}else{a.onload=ly.te;setTimeout("ly.te()",1e3)}})()
1
+ (function(a){function e(a){qsa="";if(rqs=a.className.match(/qsa_(.*)\s/,"$1"))qsa=rqs[1].replace(/\\([\&\=\?])/g,"$1");return qsa}function f(a,b){p=d.getElementById(a);c=d.createElement("div");c.className="tC";t=d.createElement("div");t.className="tT";c.appendChild(t);t.innerHTML=b;p.appendChild(c)}function g(a,b){if(typeof a.setAttribute==="function")a.setAttribute("style",b);else if(typeof a.style.setAttribute==="object")a.style.setAttribute("cssText",b)}function h(a){scr=d.createElement("script");scr.src=a;scr.type="text/javascript";d.getElementsByTagName("head")[0].appendChild(scr)}function i(a,b,c){if(d.getElementsByClassName){i=function(a,b,c){c=c||d;var e=c.getElementsByClassName(a),f=b?new RegExp("\\b"+b+"\\b","i"):null,g=[],h;for(var i=0,j=e.length;i<j;i+=1){h=e[i];if(!f||f.test(h.nodeName)){g.push(h)}}return g}}else if(d.evaluate){i=function(a,b,c){b=b||"*";c=c||d;var e=a.split(" "),f="",g="http://www.w3.org/1999/xhtml",h=d.documentElement.namespaceURI===g?g:null,i=[],j,k;for(var l=0,m=e.length;l<m;l+=1){f+="[contains(concat(' ', @class, ' '), ' "+e[l]+" ')]"}try{j=d.evaluate(".//"+b+f,c,h,0,null)}catch(n){j=d.evaluate(".//"+b+f,c,null,0,null)}while(k=j.iterateNext()){i.push(k)}return i}}else{i=function(a,b,c){b=b||"*";c=c||d;var e=a.split(" "),f=[],g=b==="*"&&c.all?c.all:c.getElementsByTagName(b),h,i=[],j;for(var k=0,l=e.length;k<l;k+=1){f.push(new RegExp("(^|\\s)"+e[k]+"(\\s|$)"))}for(var m=0,n=g.length;m<n;m+=1){h=g[m];j=false;for(var o=0,p=f.length;o<p;o+=1){j=f[o].test(h.className);if(!j){break}}if(j){i.push(h)}}return i}}return i(a,b,c)}d=document;var b="http";if(bU.indexOf("https")!=-1){b+="s"}a.te=function(){if(!c){var c=1;var f=navigator.userAgent.match(/(iphone|ipad|ipod)/i);lts=i("lyMe","div");for(var j=0,k=lts.length;j<k;j+=1){p=lts[j];vid=p.id.substring(4);cN=p.className.replace(/lyMe/,"lyte")+" lP";p.className=cN;pl=d.createElement("div");pl.id="lyte_"+vid;pl.className="pL";if(f===null){p.onclick=a.play;pW=p.style.width.match(/\d+/g)[0];pH=p.style.height.match(/\d+/g)[0];bgA="-60px";if(cN.indexOf("widget")!==-1||pW/pH<1.7)bgA="-10px";qsa=e(p);cImg='<img src="'+bU+"controls-"+pW+'.png" height="40px" width="'+pW+'px" class="ctrl" alt=""/>';pImg='<img src="'+bU+'play.png" width="83px" height="55px" alt="Click to play" style="margin-top:'+(pH/2-30)+'px;opacity:0.7;" onmouseover="this.style.opacity=1;" onmouseout="this.style.opacity=0.8;"/>';ytA="://gdata.youtube.com/feeds/api/";if(cN.indexOf("audio")!==-1){g(pl,"height:"+pH+"px;width:"+pW+"px;");pl.innerHTML=cImg}else if(cN.indexOf("playlist")!==-1){g(pl,"height:"+pH+"px;width:"+pW+"px;");pl.innerHTML=pImg+cImg;joU=b+ytA+"playlists/"+vid+"?v=2&alt=json-in-script&callback=ly.prsPL&fields=id,title,entry";h(joU)}else{g(pl,"height:"+pH+"px;width:"+pW+"px;background:url('"+b+"://img.youtube.com/vi/"+vid+"/0.jpg') no-repeat scroll center "+bgA+" rgb(0, 0, 0);background-size:cover;");pl.innerHTML=pImg+cImg;if(cN.indexOf("widget")===-1&&qsa.indexOf("showinfo=0")===-1){joU=b+ytA+"videos/"+vid+"?fields=id,title&alt=json-in-script&callback=ly.prsV";h(joU)}}p.appendChild(pl)}else{a.play(p.id)}}}var c=""};a.play=function(a){if(typeof a==="string"){tH=d.getElementById(a);aP=0}else{tH=this;tH.onclick="";aP=1}vid=tH.id.substring(4);hidef=0;if(tH.className.indexOf("hidef")!==-1){hidef=1}if(tH.className.indexOf("playlist")===-1){eU=b+"://www.youtube.com/embed/"+vid+"?"}else{eU=b+"://www.youtube.com/embed/videoseries?list="+vid+"&"}qsa=e(tH);if(tH.className.indexOf("audio")!==-1){qsa+="&autohide=0";aHgh="438";aSt="position:relative;top:-400px;"}else{aHgh=tH.clientHeight;aSt=""}tH.innerHTML='<iframe id="iF_'+vid+'" width="'+tH.clientWidth+'px" height="'+aHgh+'px" src="'+eU+"autoplay="+aP+"&wmode=opaque&rel=0&egm=0&iv_load_policy=3&hd="+hidef+qsa+'" frameborder="0" style="'+aSt+'"></iframe>';if(typeof tH.firstChild.getAttribute("kabl")=="string")tH.innerHTML="Please check Karma Blocker's config."};a.prsV=function(a){tI=a.entry.title.$t;idu=a.entry.id.$t;id="lyte_"+idu.substring(idu.length-11);f(id,tI)};a.prsPL=function(a){thumb=a.feed.entry[0].media$group.media$thumbnail[1].url;idu=a.feed.id.$t;id="lyte_"+idu.match(/PL[a-zA-Z0-9\-\_]*/)[0];title="Playlist: "+a.feed.title.$t;pl=d.getElementById(id);pH=pl.style.height;pW=pl.style.width;if(b=="https"&&thumb.indexOf("https"==-1)){thumb=thumb.replace("http://","https://")}g(pl,"height:"+pH+";width:"+pW+";background:url('"+thumb+"') no-repeat scroll center -50px rgb(0, 0, 0); background-size:cover;");f(id,title)};})(window.ly=window.ly||{});(function(){var a=window;var b=document;if(a.addEventListener){a.addEventListener("load",ly.te,false);b.addEventListener("DomContentLoaded",function(){setTimeout("ly.te()",750)},false)}else{a.onload=ly.te;setTimeout("ly.te()",1e3)}})()
lyte/lyte.js CHANGED
@@ -80,7 +80,7 @@ ly.play = function(id) {
80
  if (tH.className.indexOf("playlist") === -1) {
81
  eU=sch+"://www.youtube.com/embed/" + vid + "?"
82
  } else {
83
- eU=sch+"://www.youtube.com/embed/videoseries?list=PL" + vid + "&"
84
  }
85
 
86
  qsa=getQ(tH);
@@ -102,7 +102,7 @@ ly.prsV = function(r) {
102
  ly.prsPL = function(r) {
103
  thumb=r.feed.entry[0].media$group.media$thumbnail[1].url
104
  idu=r.feed.id.$t
105
- id="lyte_"+idu.substring(idu.length - 16)
106
  title="Playlist: "+r.feed.title.$t
107
  pl=d.getElementById(id)
108
  pH=pl.style.height;
80
  if (tH.className.indexOf("playlist") === -1) {
81
  eU=sch+"://www.youtube.com/embed/" + vid + "?"
82
  } else {
83
+ eU=sch+"://www.youtube.com/embed/videoseries?list=" + vid + "&"
84
  }
85
 
86
  qsa=getQ(tH);
102
  ly.prsPL = function(r) {
103
  thumb=r.feed.entry[0].media$group.media$thumbnail[1].url
104
  idu=r.feed.id.$t
105
+ id="lyte_"+idu.match(/PL[a-zA-Z0-9\-\_]*/)[0]
106
  title="Playlist: "+r.feed.title.$t
107
  pl=d.getElementById(id)
108
  pH=pl.style.height;
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: futtta
3
  Tags: youtube, video, lyte, lite youtube embeds, html5 video, html5, widget, youtube audio, audio, playlist, youtube playlist, hd, performance, accessibility, sidebar, lazy load
4
  Requires at least: 2.9
5
- Tested up to: 3.4
6
- Stable tag: 1.1.7
7
 
8
  High performance YouTube video, playlist and audio-only embeds which don't slow down your blog and offer optimal accessibility.
9
 
@@ -76,6 +76,10 @@ Just tell me, I like the feedback! Use the [Contact-page on my blog](http://blog
76
 
77
  == Changelog ==
78
 
 
 
 
 
79
  = 1.1.7 =
80
  * bugfix: 1.1.6 broke excerpts, as reported by Franz of [noobtech.at](http://www.noobtech.at)
81
 
2
  Contributors: futtta
3
  Tags: youtube, video, lyte, lite youtube embeds, html5 video, html5, widget, youtube audio, audio, playlist, youtube playlist, hd, performance, accessibility, sidebar, lazy load
4
  Requires at least: 2.9
5
+ Tested up to: 3.4.2
6
+ Stable tag: 1.1.8
7
 
8
  High performance YouTube video, playlist and audio-only embeds which don't slow down your blog and offer optimal accessibility.
9
 
76
 
77
  == Changelog ==
78
 
79
+ = 1.1.8 =
80
+ * bugfix: [playlists API changed: playlists can now have ID's of more than 16 chars and always should be prepended with PL](http://apiblog.youtube.com/2012/08/playlists-now-with-more-pl.html), which broke playlist rendering. Hat tip for the guys over at [dubtechnoblog.com](http://www.dubtechnoblog.com) for reporting!
81
+ * bugfix: further work on excerpts to make sure http(v|a) links in manual excerpts get replaced by a lyte player.
82
+
83
  = 1.1.7 =
84
  * bugfix: 1.1.6 broke excerpts, as reported by Franz of [noobtech.at](http://www.noobtech.at)
85
 
wp-youtube-lyte.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: WP YouTube Lyte
4
  Plugin URI: http://blog.futtta.be/wp-youtube-lyte/
5
  Description: Lite and accessible YouTube audio and video embedding.
6
  Author: Frank Goossens (futtta)
7
- Version: 1.1.7
8
  Author URI: http://blog.futtta.be/
9
  Text Domain: wp-youtube-lyte
10
  Domain Path: /languages
@@ -13,7 +13,7 @@ Domain Path: /languages
13
  $debug=false;
14
 
15
  if (!$debug) {
16
- $wyl_version="1.1.7";
17
  $wyl_file="lyte-min.js";
18
  } else {
19
  $wyl_version=rand()/1000;
@@ -70,8 +70,9 @@ function lyte_parse($the_content,$doExcerpt="false") {
70
  $scheme="http";
71
  }
72
 
73
- preg_match_all("/http(a|v):\/\/([a-zA-Z0-9\-\_]+\.|)(youtube|youtu)(\.com|\.be)\/(((watch(\?v\=|\/v\/)|.+?v\=|)([a-zA-Z0-9\-\_]{11}))|(playlist\?list\=PL([a-zA-Z0-9\-\_]{16})))([^<\s]*)/", $the_content, $matches, PREG_SET_ORDER);
74
 
 
75
 
76
  foreach($matches as $match) {
77
  preg_match("/stepSize\=([\+\-0-9]{2})/",$match[12],$sMatch);
@@ -153,7 +154,7 @@ function lyte_parse($the_content,$doExcerpt="false") {
153
  if ($doExcerpt) {$noscript="";}
154
 
155
  $lytetemplate = "<div class=\"lyMe".$audioClass.$hidefClass.$plClass.$qsaClass."\" id=\"WYL_".$vid."\" style=\"width:".$lyteSettings[2]."px;height:".$divHeight."px;overflow:hidden;\">".$noscript."</div>".$lytelinks_txt;
156
- $the_content = preg_replace("/(<p>)?http(v|a):\/\/([a-zA-Z0-9\-\_]+\.|)(youtube|youtu)(\.com|\.be)\/(((watch(\?v\=|\/v\/)|.+?v\=|)([a-zA-Z0-9\-\_]{11}))|(playlist\?list\=PL([a-zA-Z0-9\-\_]{16})))([^\s<]*)(<\/p>)?/", $lytetemplate, $the_content, 1);
157
  }
158
  lyte_initer();
159
  }
@@ -176,9 +177,9 @@ function lyte_init() {
176
  echo "<script type=\"text/javascript\" async=true src=\"".$lyteSettings['path'].$lyteSettings['file']."\"></script>";
177
  }
178
 
179
- function lyte_parse_excerpt($the_content){
180
- lyte_parse($the_content,$doExcerpt="true");
181
- return $the_content;
182
  }
183
 
184
  /** YouTube shortcode */
4
  Plugin URI: http://blog.futtta.be/wp-youtube-lyte/
5
  Description: Lite and accessible YouTube audio and video embedding.
6
  Author: Frank Goossens (futtta)
7
+ Version: 1.1.8
8
  Author URI: http://blog.futtta.be/
9
  Text Domain: wp-youtube-lyte
10
  Domain Path: /languages
13
  $debug=false;
14
 
15
  if (!$debug) {
16
+ $wyl_version="1.1.8";
17
  $wyl_file="lyte-min.js";
18
  } else {
19
  $wyl_version=rand()/1000;
70
  $scheme="http";
71
  }
72
 
73
+ $lytes_regexp="/(?:<p>)?http(v|a):\/\/([a-zA-Z0-9\-\_]+\.|)(youtube|youtu)(\.com|\.be)\/(((watch(\?v\=|\/v\/)|.+?v\=|)([a-zA-Z0-9\-\_]{11}))|(playlist\?list\=(PL[a-zA-Z0-9\-\_]*)))([^\s<]*)(<?:\/p>)?/";
74
 
75
+ preg_match_all($lytes_regexp, $the_content, $matches, PREG_SET_ORDER);
76
 
77
  foreach($matches as $match) {
78
  preg_match("/stepSize\=([\+\-0-9]{2})/",$match[12],$sMatch);
154
  if ($doExcerpt) {$noscript="";}
155
 
156
  $lytetemplate = "<div class=\"lyMe".$audioClass.$hidefClass.$plClass.$qsaClass."\" id=\"WYL_".$vid."\" style=\"width:".$lyteSettings[2]."px;height:".$divHeight."px;overflow:hidden;\">".$noscript."</div>".$lytelinks_txt;
157
+ $the_content = preg_replace($lytes_regexp, $lytetemplate, $the_content, 1);
158
  }
159
  lyte_initer();
160
  }
177
  echo "<script type=\"text/javascript\" async=true src=\"".$lyteSettings['path'].$lyteSettings['file']."\"></script>";
178
  }
179
 
180
+ function lyte_parse_excerpt($excerpt){
181
+ $excerpt=lyte_parse($excerpt,$doExcerpt="true");
182
+ return $excerpt;
183
  }
184
 
185
  /** YouTube shortcode */