WP YouTube Lyte - Version 0.1

Version Description

  • Initial version
Download this release

Release Info

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

Version 0.1

Files changed (5) hide show
  1. lyte/controls.png +0 -0
  2. lyte/lyte-min.js +1 -0
  3. lyte/play.png +0 -0
  4. readme.txt +35 -0
  5. wp-youtube-lyte.php +31 -0
lyte/controls.png ADDED
Binary file
lyte/lyte-min.js ADDED
@@ -0,0 +1 @@
 
1
+ if (typeof bU!=="string") var bU="http://futtta.be/lyte/";function lyte(){lytes=getElementsByClassName("lyte");for(var i=0;i<lytes.length;i++){lyte_id=lytes[i].id;p=document.getElementById(lyte_id);jsonUrl="http://gdata.youtube.com/feeds/api/videos/"+lyte_id+"?fields=id,title&alt=json-in-script&callback=parseMe";loadScript(jsonUrl);pl=document.createElement('div');p.appendChild(pl);p.onclick=not_so_lyte;setStyle(p,'margin:5px 0px;width:480px;height:385px;background-color:#000;');pl.id="lyte_"+lyte_id;setStyle(pl,"cursor:pointer;text-align:center;overflow:hidden;height:385px;width:480px;position:relative;margin:0px;");pl.innerHTML="<img src=\""+bU+"play.png\" style=\"margin-top: 165px;opacity:0.8\" onmouseover=\"this.style.opacity=1;\" onmouseout=\"this.style.opacity=0.8;\"/><img src=\""+bU+"controls.png\" width=\"100%\" style=\"position:absolute; left:0px; bottom:0px;\"/>";pl.style.background="#000 url(http://img.youtube.com/vi/"+lyte_id+"/0.jpg) no-repeat top center"}}function not_so_lyte(){this.onclick="";this.innerHTML="<embed src=\"http://www.youtube.com/v/"+this.id+"&autoplay=1&rel=0&egm=0\" type=\"application/x-shockwave-flash\" id=\"lyte_"+this.id+"\" wmode=\"transparent\" width=\"480\" height=\"385\" allowscriptaccess=\"always\"></embed>"}function parseMe(r){title=r.entry.title.$t;idu=r.entry.id.$t;p=document.getElementById("lyte_"+idu.substring((idu.length-11)));c=document.createElement('div');p.appendChild(c);setStyle(c,"position:relative;margin:-210px 5px;padding:5px;background-color:rgba(0,0,0,0.3);-moz-border-radius:7px;-webkit-border-radius:7px;border-radius:7px");t=document.createElement('div');c.appendChild(t);s="font-weight:bold;font-size:16px;color:#ffffff;font-family:sans-serif;text-align:left;";setStyle(t,s);t.innerHTML=title;}function setStyle(e,s){if(typeof e.setAttribute==="function")e.setAttribute('style',s);else if(typeof e.style.setAttribute==="object")e.style.setAttribute('cssText',s)}function loadScript(url){scr=document.createElement('script');scr.src=url;scr.type='text/javascript';document.getElementsByTagName('head')[0].appendChild(scr)}var getElementsByClassName=function(className,tag,elm){if(document.getElementsByClassName){getElementsByClassName=function(className,tag,elm){elm=elm||document;var elements=elm.getElementsByClassName(className),nodeName=(tag)?new RegExp("\\b"+tag+"\\b","i"):null,returnElements=[],current;for(var i=0,il=elements.length;i<il;i+=1){current=elements[i];if(!nodeName||nodeName.test(current.nodeName)){returnElements.push(current)}}return returnElements}}else if(document.evaluate){getElementsByClassName=function(className,tag,elm){tag=tag||"*";elm=elm||document;var classes=className.split(" "),classesToCheck="",xhtmlNamespace="http://www.w3.org/1999/xhtml",namespaceResolver=(document.documentElement.namespaceURI===xhtmlNamespace)?xhtmlNamespace:null,returnElements=[],elements,node;for(var j=0,jl=classes.length;j<jl;j+=1){classesToCheck+="[contains(concat(' ', @class, ' '), ' "+classes[j]+" ')]"}try{elements=document.evaluate(".//"+tag+classesToCheck,elm,namespaceResolver,0,null)}catch(e){elements=document.evaluate(".//"+tag+classesToCheck,elm,null,0,null)}while((node=elements.iterateNext())){returnElements.push(node)}return returnElements}}else{getElementsByClassName=function(className,tag,elm){tag=tag||"*";elm=elm||document;var classes=className.split(" "),classesToCheck=[],elements=(tag==="*"&&elm.all)?elm.all:elm.getElementsByTagName(tag),current,returnElements=[],match;for(var k=0,kl=classes.length;k<kl;k+=1){classesToCheck.push(new RegExp("(^|\\s)"+classes[k]+"(\\s|$)"))}for(var l=0,ll=elements.length;l<ll;l+=1){current=elements[l];match=false;for(var m=0,ml=classesToCheck.length;m<ml;m+=1){match=classesToCheck[m].test(current.className);if(!match){break}}if(match){returnElements.push(current)}}return returnElements}}return getElementsByClassName(className,tag,elm)};lyte();
lyte/play.png ADDED
Binary file
readme.txt ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Plugin Name ===
2
+ Contributors: futtta
3
+ Tags: youtube, video, lyte, lite youtube embeds
4
+ Requires at least: 2.9
5
+ Tested up to: 2.9.2
6
+ Stable tag: 0.1
7
+
8
+ WP-Youtube-lyte inserts "Lite YouTube Embeds" that look like normal embedded YouTube but without Flash unless clicked to reduce download size&time
9
+
10
+ == Description ==
11
+
12
+ WP-Youtube-lyte inserts "Lite YouTube Embeds" in your blog. These look and feel like normal embedded YouTube, but don't use Flash unless clicked on, thereby reducing download size & time substantially. Just add a YouTube-link with "httpv" instead of "http" and WP-YouTube-lyte will replace that link with the correct (flash-less) code.
13
+
14
+ WP-Youtube-lyte implements LYTE (http://blog.futtta.be/2010/04/23/high-performance-youtube-embeds/ "High Performance YouTube embeds"), which is a small javascript-solution that creates a "dummy" YouTube-player that includes the clip thumbnail and title. When clicked on, the dummy player is replaced by the Flash player.
15
+
16
+ WP-Youtube-lyte can be used together with Smart Youtube. In that case WP-Youtube-lyte will take care of the default embeds (httpv), while Smart Youtube continues to parse other types (httpvh, httpvhd, httpvp, ...).
17
+
18
+ == Installation ==
19
+
20
+ Installation is very straightforward:
21
+
22
+ 1. Upload the zip-file and unzip it in the `/wp-content/plugins/` directory
23
+ 2. Activate the plugin through the 'Plugins' menu in WordPress
24
+ 3. Place a link to a YouTube clip like this; httpv://www.youtube.com/watch?v=_SQkWbRublY
25
+
26
+ == Frequently Asked Questions ==
27
+
28
+ = Will more features be added =
29
+
30
+ Just ask, I'll see what I can do.
31
+
32
+ == Changelog ==
33
+
34
+ = 0.1 =
35
+ * Initial version
wp-youtube-lyte.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: WP Lyte Youtube
4
+ Plugin URI: http://futtta.be/wp-lyte-youtube
5
+ Description: WordPress Lite YouTube Embeds (look ma, even faster!) in posts (comments and RSS feeds to come).
6
+ Author: Frank (futtta) Goossens
7
+ Version: 0.1
8
+ Author URI: http://blog.futtta.be/
9
+ */
10
+
11
+ $wp_lyte_plugin_url = defined('WP_PLUGIN_URL') ? trailingslashit(WP_PLUGIN_URL . '/' . dirname(plugin_basename(__FILE__))) : trailingslashit(get_bloginfo('wpurl')) . PLUGINDIR . '/' . dirname(plugin_basename(__FILE__));
12
+ $lyteUrl=$wp_lyte_plugin_url."lyte/";
13
+
14
+ function lyte_parse($the_content, $side=0) {
15
+ global $lyteUrl;
16
+ if(strpos($the_content, "httpv")!==FALSE ) {
17
+ $char_codes = array('&#215;','&#8211;');
18
+ $replacements = array("x", "--");
19
+ $the_content=str_replace($char_codes, $replacements, $the_content);
20
+
21
+ preg_match_all("/httpv:\/\/([a-zA-Z0-9\-\_]+\.|)youtube\.com\/watch(\?v\=|\/v\/)([a-zA-Z0-9\-\_]{11})([^<\s]*)/", $the_content, $matches, PREG_SET_ORDER);
22
+ foreach($matches as $match) {
23
+ $the_content = preg_replace("/httpv:\/\/([a-zA-Z0-9\-\_]+\.|)youtube\.com\/watch(\?v\=|\/v\/)([a-zA-Z0-9\-\_]{11})([^\s<]*)/", "<div class=\"lyte\" id=\"".$match[3]."\" style=\"width:480;height:385;\"><noscript><a href=\"http://youtu.be/".$match[3]."\">Watch on YouTube</a></noscript><script>var bU='".$lyteUrl."';(function(){d=document;if(!document.getElementById('lytescr')){lyte=d.createElement('script');lyte.async=true;lyte.id='lytescr';lyte.src='".$lyteUrl."lyte-min.js';d.getElementsByTagName('head')[0].appendChild(lyte)}})();</script></div>", $the_content, 1);
24
+ }
25
+
26
+ }
27
+ return $the_content;
28
+ }
29
+
30
+ add_filter('the_content', 'lyte_parse', 90);
31
+ ?>