Video Embed & Thumbnail Generator - Version 2.0.6

Version Description

  • April 27, 2012 =
  • Removed swfobject.js from the plugin package. Now using the one included with WordPress. WordPress 3.3.2 contains a security fix for swfobject.js and the plugin will use the fixed version if you have upgraded WordPress (which is highly recommended).
  • Added setting to customize the formatting of titles inserted by the plugin.
  • Added settings to display a custom image when videos end instead of the first frame of the video (Flash only).
  • Fixed problem with embedded FLV files giving message "Argument Error Invalid parameter passed to method" when loading poster images.
Download this release

Release Info

Developer kylegilman
Plugin Icon 128x128 Video Embed & Thumbnail Generator
Version 2.0.6
Comparing to
See all releases

Code changes from version 2.0.5 to 2.0.6

flash/swfobject.js DELETED
@@ -1,4 +0,0 @@
1
- /* SWFObject v2.2 <http://code.google.com/p/swfobject/>
2
- is released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
3
- */
4
- var swfobject=function(){var D="undefined",r="object",S="Shockwave Flash",W="ShockwaveFlash.ShockwaveFlash",q="application/x-shockwave-flash",R="SWFObjectExprInst",x="onreadystatechange",O=window,j=document,t=navigator,T=false,U=[h],o=[],N=[],I=[],l,Q,E,B,J=false,a=false,n,G,m=true,M=function(){var aa=typeof j.getElementById!=D&&typeof j.getElementsByTagName!=D&&typeof j.createElement!=D,ah=t.userAgent.toLowerCase(),Y=t.platform.toLowerCase(),ae=Y?/win/.test(Y):/win/.test(ah),ac=Y?/mac/.test(Y):/mac/.test(ah),af=/webkit/.test(ah)?parseFloat(ah.replace(/^.*webkit\/(\d+(\.\d+)?).*#x2F;,"$1")):false,X=!+"\v1",ag=[0,0,0],ab=null;if(typeof t.plugins!=D&&typeof t.plugins[S]==r){ab=t.plugins[S].description;if(ab&&!(typeof t.mimeTypes!=D&&t.mimeTypes[q]&&!t.mimeTypes[q].enabledPlugin)){T=true;X=false;ab=ab.replace(/^.*\s+(\S+\s+\S+$)/,"$1");ag[0]=parseInt(ab.replace(/^(.*)\..*#x2F;,"$1"),10);ag[1]=parseInt(ab.replace(/^.*\.(.*)\s.*#x2F;,"$1"),10);ag[2]=/[a-zA-Z]/.test(ab)?parseInt(ab.replace(/^.*[a-zA-Z]+(.*)#x2F;,"$1"),10):0}}else{if(typeof O.ActiveXObject!=D){try{var ad=new ActiveXObject(W);if(ad){ab=ad.GetVariable("$version");if(ab){X=true;ab=ab.split(" ")[1].split(",");ag=[parseInt(ab[0],10),parseInt(ab[1],10),parseInt(ab[2],10)]}}}catch(Z){}}}return{w3:aa,pv:ag,wk:af,ie:X,win:ae,mac:ac}}(),k=function(){if(!M.w3){return}if((typeof j.readyState!=D&&j.readyState=="complete")||(typeof j.readyState==D&&(j.getElementsByTagName("body")[0]||j.body))){f()}if(!J){if(typeof j.addEventListener!=D){j.addEventListener("DOMContentLoaded",f,false)}if(M.ie&&M.win){j.attachEvent(x,function(){if(j.readyState=="complete"){j.detachEvent(x,arguments.callee);f()}});if(O==top){(function(){if(J){return}try{j.documentElement.doScroll("left")}catch(X){setTimeout(arguments.callee,0);return}f()})()}}if(M.wk){(function(){if(J){return}if(!/loaded|complete/.test(j.readyState)){setTimeout(arguments.callee,0);return}f()})()}s(f)}}();function f(){if(J){return}try{var Z=j.getElementsByTagName("body")[0].appendChild(C("span"));Z.parentNode.removeChild(Z)}catch(aa){return}J=true;var X=U.length;for(var Y=0;Y<X;Y++){U[Y]()}}function K(X){if(J){X()}else{U[U.length]=X}}function s(Y){if(typeof O.addEventListener!=D){O.addEventListener("load",Y,false)}else{if(typeof j.addEventListener!=D){j.addEventListener("load",Y,false)}else{if(typeof O.attachEvent!=D){i(O,"onload",Y)}else{if(typeof O.onload=="function"){var X=O.onload;O.onload=function(){X();Y()}}else{O.onload=Y}}}}}function h(){if(T){V()}else{H()}}function V(){var X=j.getElementsByTagName("body")[0];var aa=C(r);aa.setAttribute("type",q);var Z=X.appendChild(aa);if(Z){var Y=0;(function(){if(typeof Z.GetVariable!=D){var ab=Z.GetVariable("$version");if(ab){ab=ab.split(" ")[1].split(",");M.pv=[parseInt(ab[0],10),parseInt(ab[1],10),parseInt(ab[2],10)]}}else{if(Y<10){Y++;setTimeout(arguments.callee,10);return}}X.removeChild(aa);Z=null;H()})()}else{H()}}function H(){var ag=o.length;if(ag>0){for(var af=0;af<ag;af++){var Y=o[af].id;var ab=o[af].callbackFn;var aa={success:false,id:Y};if(M.pv[0]>0){var ae=c(Y);if(ae){if(F(o[af].swfVersion)&&!(M.wk&&M.wk<312)){w(Y,true);if(ab){aa.success=true;aa.ref=z(Y);ab(aa)}}else{if(o[af].expressInstall&&A()){var ai={};ai.data=o[af].expressInstall;ai.width=ae.getAttribute("width")||"0";ai.height=ae.getAttribute("height")||"0";if(ae.getAttribute("class")){ai.styleclass=ae.getAttribute("class")}if(ae.getAttribute("align")){ai.align=ae.getAttribute("align")}var ah={};var X=ae.getElementsByTagName("param");var ac=X.length;for(var ad=0;ad<ac;ad++){if(X[ad].getAttribute("name").toLowerCase()!="movie"){ah[X[ad].getAttribute("name")]=X[ad].getAttribute("value")}}P(ai,ah,Y,ab)}else{p(ae);if(ab){ab(aa)}}}}}else{w(Y,true);if(ab){var Z=z(Y);if(Z&&typeof Z.SetVariable!=D){aa.success=true;aa.ref=Z}ab(aa)}}}}}function z(aa){var X=null;var Y=c(aa);if(Y&&Y.nodeName=="OBJECT"){if(typeof Y.SetVariable!=D){X=Y}else{var Z=Y.getElementsByTagName(r)[0];if(Z){X=Z}}}return X}function A(){return !a&&F("6.0.65")&&(M.win||M.mac)&&!(M.wk&&M.wk<312)}function P(aa,ab,X,Z){a=true;E=Z||null;B={success:false,id:X};var ae=c(X);if(ae){if(ae.nodeName=="OBJECT"){l=g(ae);Q=null}else{l=ae;Q=X}aa.id=R;if(typeof aa.width==D||(!/%#x2F;.test(aa.width)&&parseInt(aa.width,10)<310)){aa.width="310"}if(typeof aa.height==D||(!/%#x2F;.test(aa.height)&&parseInt(aa.height,10)<137)){aa.height="137"}j.title=j.title.slice(0,47)+" - Flash Player Installation";var ad=M.ie&&M.win?"ActiveX":"PlugIn",ac="MMredirectURL="+O.location.toString().replace(/&/g,"%26")+"&MMplayerType="+ad+"&MMdoctitle="+j.title;if(typeof ab.flashvars!=D){ab.flashvars+="&"+ac}else{ab.flashvars=ac}if(M.ie&&M.win&&ae.readyState!=4){var Y=C("div");X+="SWFObjectNew";Y.setAttribute("id",X);ae.parentNode.insertBefore(Y,ae);ae.style.display="none";(function(){if(ae.readyState==4){ae.parentNode.removeChild(ae)}else{setTimeout(arguments.callee,10)}})()}u(aa,ab,X)}}function p(Y){if(M.ie&&M.win&&Y.readyState!=4){var X=C("div");Y.parentNode.insertBefore(X,Y);X.parentNode.replaceChild(g(Y),X);Y.style.display="none";(function(){if(Y.readyState==4){Y.parentNode.removeChild(Y)}else{setTimeout(arguments.callee,10)}})()}else{Y.parentNode.replaceChild(g(Y),Y)}}function g(ab){var aa=C("div");if(M.win&&M.ie){aa.innerHTML=ab.innerHTML}else{var Y=ab.getElementsByTagName(r)[0];if(Y){var ad=Y.childNodes;if(ad){var X=ad.length;for(var Z=0;Z<X;Z++){if(!(ad[Z].nodeType==1&&ad[Z].nodeName=="PARAM")&&!(ad[Z].nodeType==8)){aa.appendChild(ad[Z].cloneNode(true))}}}}}return aa}function u(ai,ag,Y){var X,aa=c(Y);if(M.wk&&M.wk<312){return X}if(aa){if(typeof ai.id==D){ai.id=Y}if(M.ie&&M.win){var ah="";for(var ae in ai){if(ai[ae]!=Object.prototype[ae]){if(ae.toLowerCase()=="data"){ag.movie=ai[ae]}else{if(ae.toLowerCase()=="styleclass"){ah+=' class="'+ai[ae]+'"'}else{if(ae.toLowerCase()!="classid"){ah+=" "+ae+'="'+ai[ae]+'"'}}}}}var af="";for(var ad in ag){if(ag[ad]!=Object.prototype[ad]){af+='<param name="'+ad+'" value="'+ag[ad]+'" />'}}aa.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+ah+">"+af+"</object>";N[N.length]=ai.id;X=c(ai.id)}else{var Z=C(r);Z.setAttribute("type",q);for(var ac in ai){if(ai[ac]!=Object.prototype[ac]){if(ac.toLowerCase()=="styleclass"){Z.setAttribute("class",ai[ac])}else{if(ac.toLowerCase()!="classid"){Z.setAttribute(ac,ai[ac])}}}}for(var ab in ag){if(ag[ab]!=Object.prototype[ab]&&ab.toLowerCase()!="movie"){e(Z,ab,ag[ab])}}aa.parentNode.replaceChild(Z,aa);X=Z}}return X}function e(Z,X,Y){var aa=C("param");aa.setAttribute("name",X);aa.setAttribute("value",Y);Z.appendChild(aa)}function y(Y){var X=c(Y);if(X&&X.nodeName=="OBJECT"){if(M.ie&&M.win){X.style.display="none";(function(){if(X.readyState==4){b(Y)}else{setTimeout(arguments.callee,10)}})()}else{X.parentNode.removeChild(X)}}}function b(Z){var Y=c(Z);if(Y){for(var X in Y){if(typeof Y[X]=="function"){Y[X]=null}}Y.parentNode.removeChild(Y)}}function c(Z){var X=null;try{X=j.getElementById(Z)}catch(Y){}return X}function C(X){return j.createElement(X)}function i(Z,X,Y){Z.attachEvent(X,Y);I[I.length]=[Z,X,Y]}function F(Z){var Y=M.pv,X=Z.split(".");X[0]=parseInt(X[0],10);X[1]=parseInt(X[1],10)||0;X[2]=parseInt(X[2],10)||0;return(Y[0]>X[0]||(Y[0]==X[0]&&Y[1]>X[1])||(Y[0]==X[0]&&Y[1]==X[1]&&Y[2]>=X[2]))?true:false}function v(ac,Y,ad,ab){if(M.ie&&M.mac){return}var aa=j.getElementsByTagName("head")[0];if(!aa){return}var X=(ad&&typeof ad=="string")?ad:"screen";if(ab){n=null;G=null}if(!n||G!=X){var Z=C("style");Z.setAttribute("type","text/css");Z.setAttribute("media",X);n=aa.appendChild(Z);if(M.ie&&M.win&&typeof j.styleSheets!=D&&j.styleSheets.length>0){n=j.styleSheets[j.styleSheets.length-1]}G=X}if(M.ie&&M.win){if(n&&typeof n.addRule==r){n.addRule(ac,Y)}}else{if(n&&typeof j.createTextNode!=D){n.appendChild(j.createTextNode(ac+" {"+Y+"}"))}}}function w(Z,X){if(!m){return}var Y=X?"visible":"hidden";if(J&&c(Z)){c(Z).style.visibility=Y}else{v("#"+Z,"visibility:"+Y)}}function L(Y){var Z=/[\\\"<>\.;]/;var X=Z.exec(Y)!=null;return X&&typeof encodeURIComponent!=D?encodeURIComponent(Y):Y}var d=function(){if(M.ie&&M.win){window.attachEvent("onunload",function(){var ac=I.length;for(var ab=0;ab<ac;ab++){I[ab][0].detachEvent(I[ab][1],I[ab][2])}var Z=N.length;for(var aa=0;aa<Z;aa++){y(N[aa])}for(var Y in M){M[Y]=null}M=null;for(var X in swfobject){swfobject[X]=null}swfobject=null})}}();return{registerObject:function(ab,X,aa,Z){if(M.w3&&ab&&X){var Y={};Y.id=ab;Y.swfVersion=X;Y.expressInstall=aa;Y.callbackFn=Z;o[o.length]=Y;w(ab,false)}else{if(Z){Z({success:false,id:ab})}}},getObjectById:function(X){if(M.w3){return z(X)}},embedSWF:function(ab,ah,ae,ag,Y,aa,Z,ad,af,ac){var X={success:false,id:ah};if(M.w3&&!(M.wk&&M.wk<312)&&ab&&ah&&ae&&ag&&Y){w(ah,false);K(function(){ae+="";ag+="";var aj={};if(af&&typeof af===r){for(var al in af){aj[al]=af[al]}}aj.data=ab;aj.width=ae;aj.height=ag;var am={};if(ad&&typeof ad===r){for(var ak in ad){am[ak]=ad[ak]}}if(Z&&typeof Z===r){for(var ai in Z){if(typeof am.flashvars!=D){am.flashvars+="&"+ai+"="+Z[ai]}else{am.flashvars=ai+"="+Z[ai]}}}if(F(Y)){var an=u(aj,am,ah);if(aj.id==ah){w(ah,true)}X.success=true;X.ref=an}else{if(aa&&A()){aj.data=aa;P(aj,am,ah,ac);return}else{w(ah,true)}}if(ac){ac(X)}})}else{if(ac){ac(X)}}},switchOffAutoHideShow:function(){m=false},ua:M,getFlashPlayerVersion:function(){return{major:M.pv[0],minor:M.pv[1],release:M.pv[2]}},hasFlashPlayerVersion:F,createSWF:function(Z,Y,X){if(M.w3){return u(Z,Y,X)}else{return undefined}},showExpressInstall:function(Z,aa,X,Y){if(M.w3&&A()){P(Z,aa,X,Y)}},removeSWF:function(X){if(M.w3){y(X)}},createCSS:function(aa,Z,Y,X){if(M.w3){v(aa,Z,Y,X)}},addDomLoadEvent:K,addLoadEvent:s,getQueryParamValue:function(aa){var Z=j.location.search||j.location.hash;if(Z){if(/\?/.test(Z)){Z=Z.split("?")[1]}if(aa==null){return L(Z)}var Y=Z.split("&");for(var X=0;X<Y.length;X++){if(Y[X].substring(0,Y[X].indexOf("="))==aa){return L(Y[X].substring((Y[X].indexOf("=")+1)))}}}return""},expressInstallCallback:function(){if(a){var X=c(R);if(X&&l){X.parentNode.replaceChild(l,X);if(Q){w(Q,true);if(M.ie&&M.win){l.style.display="block"}}if(E){E(B)}}a=false}}}}();
kg_video_plugin.js CHANGED
@@ -154,7 +154,20 @@ function kg_insert_shortcode() {
154
}, "json" );
155
156
var shortcode = "";
157
- if (document.getElementById('videotitle').value != "") { shortcode += '<strong>' + document.getElementById('videotitle').value + '</strong><br />'; }
158
if (url !="") {
159
shortcode += ' [FMP';
160
if (document.getElementById('attachments[singleurl][kgflashmediaplayer-poster]').value !="") { shortcode += ' poster="' + document.getElementById("attachments[singleurl][kgflashmediaplayer-poster]").value + '"'; }
154
}, "json" );
155
156
var shortcode = "";
157
+ if (document.getElementById('videotitle').value != "") {
158
+ var titlecode = unescape(document.getElementById('attachments[singleurl][kgflashmediaplayer-titlecode]').value);
159
+ titlecode=titlecode.replace(/\\'/g,'\'');
160
+ titlecode=titlecode.replace(/\\"/g,'"');
161
+ titlecode=titlecode.replace(/\\0/g,'\0');
162
+ titlecode=titlecode.replace(/\\\\/g,'\\');
163
+ if ( titlecode.substr(0,1) != '<' ) { titlecode = '<'+titlecode; }
164
+ if ( titlecode.substr(-1,1) != '>' ) { titlecode = titlecode+'>'; }
165
+ var endtitlecode = titlecode.replace('<', '</');
166
+ endtitlecode = endtitlecode.split(' ');
167
+ endtitlecode = endtitlecode[0];
168
+ if ( endtitlecode.substr(-1,1) != '>' ) { endtitlecode = endtitlecode+'>'; }
169
+ shortcode += titlecode + document.getElementById('videotitle').value + endtitlecode + '<br />';
170
+ }
171
if (url !="") {
172
shortcode += ' [FMP';
173
if (document.getElementById('attachments[singleurl][kgflashmediaplayer-poster]').value !="") { shortcode += ' poster="' + document.getElementById("attachments[singleurl][kgflashmediaplayer-poster]").value + '"'; }
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: kylegilman
3
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=kylegilman@gmail.com&item_name=Video%20Embed%20And%20Thumbnail%20Generator%20Plugin%20Donation/
4
Tags: video, html5, shortcode, thumbnail, ffmpeg, embed, mobile, webm, ogg, h.264
5
Requires at least: 3.0
6
- Tested up to: 3.3.1
7
- Stable tag: 2.0.5
8
9
Generates thumbnails, HTML5-compliant videos, and embed codes for locally hosted videos. Requires FFMPEG for thumbnails and encodes.
10
@@ -47,9 +47,9 @@ After you save the post, the thumbnail file will be registered in the Wordpress
47
48
`<iframe width="960" height="540" frameborder="0" scrolling="no" src="http://www.kylegilman.net/?attachment_id=1906"></iframe>`
49
50
- = If you want to further modify the way the Flash video player works, you can add the following options inside the [FMP] tag. These will override anything you’ve set in the plugin settings. =
51
52
- * `poster="http://www.example.com/image.jpg"` sets the thumbnail
53
* `width="xxx"`
54
* `height="xxx"`
55
* `controlbar="docked/floating/none"` sets the controlbar position. HTML5 videos only respond to the "none" option.
@@ -58,6 +58,7 @@ After you save the post, the thumbnail file will be registered in the Wordpress
58
59
= These options will only affect Flash video elements. They will have no effect on HTML5 videos. =
60
61
* `autohide="true/false"` specify whether to autohide the control bar after a few seconds.
62
* `playbutton="true/false"` turns the big play button overlay in the middle of the video on or off.
63
* `streamtype="live/recorded/DVR"` I honestly don’t know what this is for.
@@ -113,6 +114,12 @@ Because I can't figure out how to do it. Windows works a little differently from
113
114
== Changelog ==
115
116
= 2.0.5 - April 20, 2012 =
117
* Fixed "Wrong datatype for second argument" error on line 339 and subsequent automatic replacement of original videos with Mobile/H.264 versions whether they exist or not.
118
3
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=kylegilman@gmail.com&item_name=Video%20Embed%20And%20Thumbnail%20Generator%20Plugin%20Donation/
4
Tags: video, html5, shortcode, thumbnail, ffmpeg, embed, mobile, webm, ogg, h.264
5
Requires at least: 3.0
6
+ Tested up to: 3.3.2
7
+ Stable tag: 2.0.6
8
9
Generates thumbnails, HTML5-compliant videos, and embed codes for locally hosted videos. Requires FFMPEG for thumbnails and encodes.
10
47
48
`<iframe width="960" height="540" frameborder="0" scrolling="no" src="http://www.kylegilman.net/?attachment_id=1906"></iframe>`
49
50
+ = If you want to further modify the way the video player works, you can add the following options inside the [FMP] tag. These will override anything you’ve set in the plugin settings. =
51
52
+ * `poster="http://www.example.com/image.jpg"` sets the thumbnail.
53
* `width="xxx"`
54
* `height="xxx"`
55
* `controlbar="docked/floating/none"` sets the controlbar position. HTML5 videos only respond to the "none" option.
58
59
= These options will only affect Flash video elements. They will have no effect on HTML5 videos. =
60
61
+ * `endofvideooverlay="http://www.example.com/end_image.jpg` sets the image shown when the video ends.
62
* `autohide="true/false"` specify whether to autohide the control bar after a few seconds.
63
* `playbutton="true/false"` turns the big play button overlay in the middle of the video on or off.
64
* `streamtype="live/recorded/DVR"` I honestly don’t know what this is for.
114
115
== Changelog ==
116
117
+ = 2.0.6 - April 27, 2012 =
118
+ * Removed swfobject.js from the plugin package. Now using the one included with WordPress. WordPress 3.3.2 contains a security fix for swfobject.js and the plugin will use the fixed version if you have upgraded WordPress (which is highly recommended).
119
+ * Added setting to customize the formatting of titles inserted by the plugin.
120
+ * Added settings to display a custom image when videos end instead of the first frame of the video (Flash only).
121
+ * Fixed problem with embedded FLV files giving message "Argument Error � Invalid parameter passed to method" when loading poster images.
122
+
123
= 2.0.5 - April 20, 2012 =
124
* Fixed "Wrong datatype for second argument" error on line 339 and subsequent automatic replacement of original videos with Mobile/H.264 versions whether they exist or not.
125
video-embed-thumbnail-generator.php CHANGED
@@ -3,7 +3,7 @@
3
Plugin Name: Video Embed & Thumbnail Generator
4
Plugin URI: http://www.kylegilman.net/2011/01/18/video-embed-thumbnail-generator-wordpress-plugin/
5
Description: Generates thumbnails, HTML5-compliant videos, and embed codes for locally hosted videos. Requires FFMPEG for thumbnails and encodes. <a href="options-general.php?page=video-embed-thumbnail-generator.php">Settings</a> | <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=kylegilman@gmail.com&item_name=Video%20Embed%20And%20Thumbnail%20Generator%20Plugin%20Donation/">Donate</a>
6
- Version: 2.0.5
7
Author: Kyle Gilman
8
Author URI: http://www.kylegilman.net/
9
@@ -108,29 +108,29 @@ function rrmdir($dir) {
108
109
function kg_check_ffmpeg_exists() {
110
111
- $exec_enabled = false;
112
- $ffmpeg_exists = false;
113
- $output = array();
114
- $ffmpeg_path = get_option('wp_FMP_ffmpeg');
115
- $uploads = wp_upload_dir();
116
117
- if(function_exists('exec')) {
118
- $exec_enabled = true;
119
- exec ( get_option('wp_FMP_ffmpeg').'/ffmpeg -i '.plugins_url("", __FILE__).'/flash/skin/images/PlayNormal.png '.$uploads['path'].'/ffmpeg_exists_test.jpg', $output, $returnvalue );
120
- }
121
122
- if ( $exec_enabled == true && file_exists($uploads['path'].'/ffmpeg_exists_test.jpg') ) { //if FFMPEG has executed successfully
123
- update_option('wp_FMP_ffmpeg_exists', "true");
124
- $ffmpeg_exists = true;
125
- unlink($uploads['path'].'/ffmpeg_exists_test.jpg');
126
- }
127
- else { update_option('wp_FMP_ffmpeg_exists', "notinstalled"); }
128
129
- $output_output = implode("/n", $output);
130
131
- $arr = array ("exec_enabled"=>$exec_enabled, "ffmpeg_exists"=>$ffmpeg_exists, "return_value"=>$returnvalue, "output"=>$output_output);
132
133
- return $arr;
134
}
135
136
function kg_encodevideo_info($movieurl, $postID) {
@@ -248,6 +248,7 @@ function video_embed_thumbnail_generator_activate() {
248
define("wp_FMP_default_HTML5", "true", true);
249
define("wp_FMP_default_controlbar_style", "docked", true);
250
define("wp_FMP_default_poster", "", true);
251
define("wp_FMP_default_autohide", "true", true);
252
define("wp_FMP_default_autoplay", "false", true);
253
define("wp_FMP_default_loop", "false", true);
@@ -265,6 +266,7 @@ function video_embed_thumbnail_generator_activate() {
265
define("wp_FMP_default_encodewebm", "true", true);
266
define("wp_FMP_default_vpre", "false", true);
267
define("wp_FMP_default_template", "false", true);
268
269
add_option('wp_FMP_swfobject', wp_FMP_swfobject_default);
270
add_option('wp_FMP_flashplayer', wp_FMP_flashplayer_default);
@@ -273,6 +275,7 @@ function video_embed_thumbnail_generator_activate() {
273
add_option('wp_FMP_HTML5', wp_FMP_default_HTML5);
274
add_option('wp_FMP_controlbar_style', wp_FMP_default_controlbar_style);
275
add_option('wp_FMP_poster', wp_FMP_default_poster);
276
add_option('wp_FMP_autohide', wp_FMP_default_autohide);
277
add_option('wp_FMP_autoplay', wp_FMP_default_autoplay);
278
add_option('wp_FMP_loop', wp_FMP_default_loop);
@@ -290,342 +293,361 @@ function video_embed_thumbnail_generator_activate() {
290
add_option('wp_FMP_encodewebm', wp_FMP_default_encodewebm);
291
add_option('wp_FMP_vpre', wp_FMP_default_vpre);
292
add_option('wp_FMP_template', wp_FMP_default_template);
293
294
kg_check_ffmpeg_exists();
295
296
}
297
-
298
register_activation_hook( __FILE__, 'video_embed_thumbnail_generator_activate' );
299
300
function addSWFObject() {
301
if(get_option('wp_FMP_swfobject') == "true") {
302
- echo "\n<script src=\"".plugins_url("", __FILE__)."/flash/swfobject.js\" type=\"text/javascript\"></script>\n";
303
}
304
}
305
306
function FMP_shortcode($atts, $content = ''){
307
308
309
- // workaround for relative video URL (contributed by Lee Fernandes)
310
- if(substr($content, 0, 1) == '/') $content = get_bloginfo('url').$content;
311
312
- $query_atts = shortcode_atts(
313
- array('width' => get_option('wp_FMP_width'),
314
- 'height' => get_option('wp_FMP_height'),
315
- 'controlbar' => get_option('wp_FMP_controlbar_style'),
316
- 'autohide' => get_option('wp_FMP_autohide'),
317
- 'poster' => get_option('wp_FMP_poster'),
318
- 'playbutton' => get_option('wp_FMP_playbutton'),
319
- 'loop' => get_option('wp_FMP_loop'),
320
- 'autoplay' => get_option('wp_FMP_autoplay'),
321
- 'streamtype' => get_option('wp_FMP_stream_type'),
322
- 'scalemode' => get_option('wp_FMP_scale_mode'),
323
- 'backgroundcolor' => get_option('wp_FMP_bgcolor'),
324
- 'configuration' => get_option('wp_FMP_configuration'),
325
- 'skin' => get_option('wp_FMP_skin')), $atts);
326
-
327
- $div_suffix = substr(uniqid(rand(), true),0,4);
328
-
329
- global $wpdb;
330
- $query = "SELECT ID FROM {$wpdb->posts} WHERE guid='$content'";
331
- $id = $wpdb->get_var($query);
332
- $moviefiletype = pathinfo(trim($content), PATHINFO_EXTENSION);
333
- $flashcompatible = array("flv", "f4v", "mp4", "mov", "m4v");
334
-
335
- if ($id != "") { $encodevideo_info = kg_encodevideo_info(trim($content), $id); }
336
- else { $encodevideo_info = kg_encodevideo_info(trim($content), 'singleurl'); }
337
-
338
- $video_swf = plugins_url('', __FILE__)."/flash/StrobeMediaPlayback.swf";
339
- $minimum_flash = "10.1.0";
340
-
341
- if ( in_array($moviefiletype, $flashcompatible) ) { $flashvars = "{src:'".urlencode(trim($content))."'"; }
342
- else { $flashvars = "{'src':'".urlencode(trim($encodevideo_info['mobileurl']))."'"; }
343
-
344
- if($query_atts["controlbar"] != '') {
345
- $flashvars .= ", 'controlBarMode':'".$query_atts["controlbar"]."'";
346
- }
347
- if($query_atts["autohide"] != '') {
348
- $flashvars .= ", 'controlBarAutoHide':'".$query_atts["autohide"]."'";
349
- }
350
- if($query_atts["poster"] != '') {
351
- $flashvars .= ", 'poster':'".urlencode(trim($query_atts["poster"]))."'";
352
- }
353
- if($query_atts["playbutton"] != '') {
354
- $flashvars .= ", 'playButtonOverlay':'".$query_atts["playbutton"]."'";
355
- }
356
- if($query_atts["loop"] != '') {
357
- $flashvars .= ", 'loop':'".$query_atts["loop"]."'";
358
- }
359
- if($query_atts["autoplay"] != '') {
360
- $flashvars .= ", 'autoPlay':'".$query_atts["autoplay"]."'";
361
- }
362
- if($query_atts["streamtype"] != '') {
363
- $flashvars .= ", 'streamType':'".$query_atts["streamtype"]."'";
364
- }
365
- if($query_atts["scalemode"] != '') {
366
- $flashvars .= ", 'scaleMode':'".$query_atts["scalemode"]."'";
367
- }
368
- if($query_atts["backgroundcolor"] != '') {
369
- $flashvars .= ", 'backgroundColor':'".$query_atts["backgroundcolor"]."'";
370
- }
371
- if($query_atts["configuration"] != '') {
372
- $flashvars .= ", 'configuration':'".urlencode($query_atts["configuration"])."'";
373
- }
374
- if($query_atts["skin"] != '') {
375
- $flashvars .= ", 'skin':'".urlencode($query_atts["skin"])."'";
376
- }
377
-
378
- $flashvars .= "}";
379
380
- $params = "{'allowfullscreen':'true', 'allowscriptaccess':'always', 'base':'".plugins_url("", __FILE__)."/flash/'}";
381
-
382
- if(get_option('wp_FMP_HTML5') == "true") {
383
- include_once dirname( __FILE__ ) .'/mdetect.php';
384
- $uagent_obj = new uagent_info();
385
- $isAndroid = $uagent_obj->DetectAndroid(); //determine if we're running on an Android device
386
- $isTierIphone = $uagent_obj->DetectTierIphone(); //determine if we're running on a mobile device that plays iPhone-optimized video
387
- $moviefilebasename = pathinfo(trim($content), PATHINFO_FILENAME);
388
- $h264compatible = array("mp4", "mov", "m4v");
389
-
390
- $code = "<div id=\"flashcontent".$div_suffix."\">";
391
- $code .= "<video ";
392
- if ($query_atts["loop"] == 'true') { $code .= "loop='loop' " ;}
393
- if ($query_atts["autoplay"] == 'true') { $code .= "autoplay='autoplay' " ;}
394
- if ($query_atts["controlbar"] != 'none') { $code .= "controls='controls' " ;}
395
- if ($isAndroid) { $code .= "onclick='this.play();' "; }
396
- $code .= "preload='metadata' ";
397
- if($query_atts["poster"] != '' && !$isAndroid) {
398
- $code .= "poster='".$query_atts["poster"]."' ";
399
- }
400
- if($query_atts["poster"] != '' && $isAndroid) {
401
- $code .= "poster='".plugins_url('', __FILE__)."/images/androidthumb.php?src=".$query_atts["poster"]."' ";
402
- }
403
- $code .= "width='".$query_atts["width"]."' height='".$query_atts["height"]."'";
404
- $code .= ">\n";
405
-
406
- if ( in_array($moviefiletype, $h264compatible) ) {
407
- if ( $encodevideo_info["mobile_exists"] && $isTierIphone ) {
408
- $code .= "<source src='".$encodevideo_info["mobileurl"]."'";
409
- }
410
- else { $code .= "<source src='".trim($content)."'"; }
411
- if (!$isAndroid) { $code.= " type='video/mp4'"; }
412
- $code .=">\n";
413
}
414
- else { if ( $encodevideo_info["mobile_exists"] ) {
415
$code .= "<source src='".$encodevideo_info["mobileurl"]."'";
416
- if (!$isAndroid) { $code.= " type='video/mp4'"; }
417
- $code .=">\n";
418
- } }
419
- if ( $encodevideo_info["webm_exists"] ) { $code .= "<source src='".$encodevideo_info["webmurl"]."' type='video/webm'>\n"; }
420
- if ( $encodevideo_info["ogg_exists"] ) { $code .= "<source src='".$encodevideo_info["oggurl"]."' type='video/ogg'>\n"; }
421
- if ( !in_array($moviefiletype, $flashcompatible) && $encodevideo_info["mobile_exists"] ) { // Flash fallback if WEBM/OGV embed
422
- $flashvars_remove = array("{", "}", "'");
423
- $flashvars_reformat = str_replace($flashvars_remove, "", $flashvars);
424
- $flashvars_reformat = str_replace(":", "=", $flashvars_reformat);
425
- $flashvars_reformat = str_replace(", ", "&", $flashvars_reformat);
426
- $code .= '<object width="'.trim($query_atts["width"]).'" height="'.trim($query_atts["height"]).'" type="application/x-shockwave-flash" data="'.$video_swf.'">'."\n";
427
- $code .= '<param name="movie" value="'.$video_swf.'" /></param>'."\n";
428
- $code .= '<param name="flashvars" value="'.$flashvars_reformat.'" /></param>'."\n";
429
- $code .= '<param name="base" value="'.plugins_url('', __FILE__).'/flash/" /></param>'."\n";
430
- $code .= '<param name="allowFullScreen" value="true" /></param>'."\n";
431
- $code .= '<param name="allowscriptaccess" value="always" /></param>'."\n";
432
- $code .= '</object>';
433
}
434
- $code .= "</video>\n";
435
- $code .= "</div>\n\n";
436
-
437
- /* if ($id !="") {
438
- $iframeurl = site_url('/')."?attachment_id=".$id;
439
- $iframecode = '<iframe src="'.$iframeurl.'" frameborder="0" scrolling="no" width="'.$query_atts['width'].'" height="'.$query_atts["height"].'"></iframe>';
440
- $code .= "<div style='background-color:#e8e8e8; width:".$query_atts['width']."px; height:25px; margin-top:-25px; padding:5px; font-size:8pt;'>Embed code: <input style='height:10px; background-color:#f4f4f4;' type='text' value='".$iframecode."' width='10' onClick='this.select();'></div>\n";
441
- } */
442
- } else {
443
- if ( in_array($moviefiletype, $flashcompatible) ) { $code = "<div id=\"flashcontent".$div_suffix."\">".get_option('wp_FMP_flashplayer')."</div>\n\n"; }
444
}
445
-
446
- if ( in_array($moviefiletype, $flashcompatible) ) {
447
- $code .= "<script type=\"text/javascript\">\n\t";
448
- $code .= "swfobject.embedSWF('".$video_swf."', 'flashcontent".$div_suffix."', '".trim($query_atts['width'])."', '".trim($query_atts['height'])."', '".$minimum_flash."', '".plugins_url("", __FILE__)."/flash/expressInstall.swf', $flashvars, $params)\n";
449
- $code .= "</script>\n";
450
}
451
452
- return $code;
453
}
454
add_shortcode('FMP', 'FMP_shortcode');
455
456
function addFMPOptionsPage() {
457
- add_options_page('Video Embed & Thumbnail Generator', 'Video Embed & Thumbnail Generator', 'administrator', basename(__FILE__), 'FMPOptionsPage');
458
- }
459
460
function FMPOptionsPage() {
461
462
- define("wp_FMP_swfobject_default", "true", true);
463
- define("wp_FMP_flashplayer_default", "<strong>Please upgrade Flash Player</strong> This content is shown when the user does not have a correct Flash Player version installed.", true);
464
- define("wp_FMP_default_width", "640", true);
465
- define("wp_FMP_default_height", "360", true);
466
- define("wp_FMP_default_HTML5", "true", true);
467
- define("wp_FMP_default_controlbar_style", "docked", true);
468
- define("wp_FMP_default_poster", "", true);
469
- define("wp_FMP_default_autohide", "true", true);
470
- define("wp_FMP_default_autoplay", "false", true);
471
- define("wp_FMP_default_loop", "false", true);
472
- define("wp_FMP_default_playbutton", "true", true);
473
- define("wp_FMP_default_stream_type", "liveOrRecorded", true);
474
- define("wp_FMP_default_scale_mode", "letterbox", true);
475
- define("wp_FMP_default_bgcolor", "", true);
476
- define("wp_FMP_default_configuration", "", true);
477
- define("wp_FMP_default_skin", plugins_url("", __FILE__)."/flash/skin/kg_skin.xml", true);
478
- define("wp_FMP_default_ffmpeg", "/usr/local/bin", true);
479
- define("wp_FMP_default_mobile_res", "480", true);
480
- define("wp_FMP_default_encodemobile", "true", true);
481
- define("wp_FMP_default_encodeogg", "false", true);
482
- define("wp_FMP_default_encodewebm", "true", true);
483
- define("wp_FMP_default_vpre", "false", true);
484
- define("wp_FMP_default_template", "false", true);
485
486
- if (isset($_POST['wp_FMP_reset'])) {
487
- update_option('wp_FMP_swfobject', wp_FMP_swfobject_default);
488
- update_option('wp_FMP_HTML5', wp_FMP_default_HTML5);
489
- update_option('wp_FMP_width', wp_FMP_default_width);
490
- update_option('wp_FMP_height', wp_FMP_default_height);
491
- update_option('wp_FMP_flashplayer', wp_FMP_flashplayer_default);
492
- update_option('wp_FMP_controlbar_style', wp_FMP_default_controlbar_style);
493
- update_option('wp_FMP_poster', wp_FMP_default_poster);
494
- update_option('wp_FMP_autohide', wp_FMP_default_autohide);
495
- update_option('wp_FMP_autoplay', wp_FMP_default_autoplay);
496
- update_option('wp_FMP_loop', wp_FMP_default_loop);
497
- update_option('wp_FMP_playbutton', wp_FMP_default_playbutton);
498
- update_option('wp_FMP_stream_type', wp_FMP_default_stream_type);
499
- update_option('wp_FMP_scale_mode', wp_FMP_default_scale_mode);
500
- update_option('wp_FMP_bgcolor', wp_FMP_default_bgcolor);
501
- update_option('wp_FMP_configuration', wp_FMP_default_configuration);
502
- update_option('wp_FMP_skin', wp_FMP_default_skin);
503
- update_option('wp_FMP_ffmpeg', wp_FMP_default_ffmpeg);
504
- update_option('wp_FMP_mobile_res', wp_FMP_default_mobile_res);
505
- update_option('wp_FMP_encodemobile', wp_FMP_default_encodemobile);
506
- update_option('wp_FMP_encodeogg', wp_FMP_default_encodeogg);
507
- update_option('wp_FMP_encodewebm', wp_FMP_default_encodewebm);
508
- update_option('wp_FMP_vpre', wp_FMP_default_vpre);
509
- update_option('wp_FMP_template', wp_FMP_default_template);
510
-
511
- echo "<div class='updated'><p><strong>Video Embed & Thumbnail Generator plugin reset to default settings</strong></p></div>";
512
513
- $ffmpeg_info = kg_check_ffmpeg_exists();
514
515
- if ( $ffmpeg_info['exec_enabled'] == false ) {
516
- echo "<div class='error'><p><strong>EXEC function is disabled in PHP settings. Embed codes will work, but video thumbnail generation and Mobile/HTML5 encoding will not. Contact your System Administrator to find out if you can enable EXEC</strong></p></div>";
517
- }
518
- elseif ( $ffmpeg_info['ffmpeg_exists'] == false ) {
519
- echo "<div class='error'><p><strong>FFMPEG not found at ".get_option('wp_FMP_ffmpeg').". Embed codes will work, but video thumbnail generation and Mobile/HTML5 encoding will not.</strong></p></div>";
520
- }
521
-
522
- }
523
524
- if (isset($_POST['wp_FMP_update'])) {
525
- check_admin_referer();
526
- $use_swfobject = $_POST[wp_FMP_swfobject];
527
- $use_html5fallback = $_POST[wp_FMP_HTML5];
528
- $use_autohide = $_POST[wp_FMP_autohide];
529
- $use_autoplay = $_POST[wp_FMP_autoplay];
530
- $use_loop = $_POST[wp_FMP_loop];
531
- $use_playbutton = $_POST[wp_FMP_playbutton];
532
- $use_encodemobile = $_POST[wp_FMP_encodemobile];
533
- $use_encodeogg = $_POST[wp_FMP_encodeogg];
534
- $use_encodewebm = $_POST[wp_FMP_encodewebm];
535
- $use_vpre = $_POST[wp_FMP_vpre];
536
- $use_template = $_POST[wp_FMP_template];
537
-
538
- if ($use_swfobject == 'use') {
539
- update_option(wp_FMP_swfobject, "true");
540
- } else {
541
- update_option(wp_FMP_swfobject, "false");
542
- }
543
-
544
- if ($use_html5fallback == 'use') {
545
- update_option(wp_FMP_HTML5, "true");
546
- } else {
547
- update_option(wp_FMP_HTML5, "false");
548
- }
549
-
550
- if ($use_autohide == 'use') {
551
- update_option(wp_FMP_autohide, "true");
552
- } else {
553
- update_option(wp_FMP_autohide, "false");
554
- }
555
-
556
- if ($use_autoplay == 'use') {
557
- update_option(wp_FMP_autoplay, "true");
558
- } else {
559
- update_option(wp_FMP_autoplay, "false");
560
- }
561
-
562
- if ($use_loop == 'use') {
563
- update_option(wp_FMP_loop, "true");
564
- } else {
565
- update_option(wp_FMP_loop, "false");
566
- }
567
-
568
- if ($use_playbutton == 'use') {
569
- update_option(wp_FMP_playbutton, "true");
570
- } else {
571
- update_option(wp_FMP_playbutton, "false");
572
- }
573
-
574
- if ($use_encodemobile == 'use') {
575
- update_option(wp_FMP_encodemobile, "true");
576
- } else {
577
- update_option(wp_FMP_encodemobile, "false");
578
- }
579
580
- if ($use_encodeogg == 'use') {
581
- update_option(wp_FMP_encodeogg, "true");
582
- } else {
583
- update_option(wp_FMP_encodeogg, "false");
584
- }
585
586
- if ($use_encodewebm == 'use') {
587
- update_option(wp_FMP_encodewebm, "true");
588
- } else {
589
- update_option(wp_FMP_encodewebm, "false");
590
- }
591
592
- if ($use_vpre == 'use') {
593
- update_option(wp_FMP_vpre, "true");
594
- } else {
595
- update_option(wp_FMP_vpre, "false");
596
- }
597
598
- if ($use_template == 'use') {
599
- update_option(wp_FMP_template, "true");
600
- } else {
601
- update_option(wp_FMP_template, "false");
602
- }
603
604
- update_option('wp_FMP_mobile_res', $_POST[wp_FMP_mobile_res]);
605
- update_option('wp_FMP_width', $_POST[wp_FMP_width]);
606
- update_option('wp_FMP_height', $_POST[wp_FMP_height]);
607
- update_option('wp_FMP_bgcolor', $_POST[wp_FMP_bgcolor]);
608
- update_option('wp_FMP_configuration', $_POST[wp_FMP_configuration]);
609
- update_option('wp_FMP_skin', $_POST[wp_FMP_skin]);
610
- update_option('wp_FMP_flashplayer', $_POST[wp_FMP_flashplayer]);
611
- update_option('wp_FMP_controlbar_style', $_POST[wp_FMP_controlbar_style]);
612
- update_option('wp_FMP_stream_type', $_POST[wp_FMP_stream_type]);
613
- update_option('wp_FMP_scale_mode', $_POST[wp_FMP_scale_mode]);
614
- update_option('wp_FMP_poster', $_POST[wp_FMP_poster]);
615
- update_option('wp_FMP_ffmpeg', $_POST[wp_FMP_ffmpeg]);
616
617
- echo "<div class='updated'><p><strong>Video Embed & Thumbnail Generator plugin settings updated</strong></p></div>";
618
619
620
- $ffmpeg_info = kg_check_ffmpeg_exists();
621
622
- if ( $ffmpeg_info['exec_enabled'] == false ) {
623
- echo "<div class='error'><p><strong>EXEC function is disabled in PHP settings. Embed codes will work, but video thumbnail generation and Mobile/HTML5 encoding will not. Contact your System Administrator to find out if you can enable EXEC</strong></p></div>";
624
- }
625
- elseif ( $ffmpeg_info['ffmpeg_exists'] == false ) {
626
- echo "<div class='error'><p><strong>FFMPEG not found at ".get_option('wp_FMP_ffmpeg').". Embed codes will work, but video thumbnail generation and Mobile/HTML5 encoding will not.</strong></p></div>";
627
- }
628
}
629
630
?>
631
@@ -754,7 +776,7 @@ function FMPOptionsPage() {
754
</th>
755
<td width="10"></td>
756
<td>
757
- <input name="wp_FMP_ffmpeg" id="wp_FMP_ffmpeg" type="text" value="<?php echo get_option('wp_FMP_ffmpeg') ?>" /><br />
758
<em>Don't include trailing slash. Example: /usr/local/bin</em>
759
</td>
760
</tr>
@@ -775,13 +797,23 @@ function FMPOptionsPage() {
775
<em><small>Check this if your installed version of FFMPEG is old enough that libx264 requires vpre flags to operate (Dreamhost users must turn this on).<br />This should help if you can encode WEBM or OGV files but H264/Mobile files fail. It will cause newer versions of FFMPEG to fail and probably won't work on Windows servers.</em></small>
776
</td>
777
</tr>
778
<tr>
779
<th scope="row" valign="top" align="left">
780
<label>Flash Player not installed message:</label>
781
</th>
782
<td width="10"></td>
783
<td>
784
- <textarea name="wp_FMP_flashplayer" id="wp_FMP_flashplayer" rows="5" cols="50"><?php echo get_option('wp_FMP_flashplayer') ?></textarea><br />
785
<em>This message will only be shown if HTML5 video fallback is disabled</em>
786
</td>
787
</tr>
@@ -885,7 +917,18 @@ function FMPOptionsPage() {
885
<tr>
886
<th colspan="3"><h4>The following options will only affect Flash playback</h4></th><td>
887
</td>
888
- </tr>
889
<tr>
890
<th scope="row" valign="top" align="left">
891
<label>Default background color:</label>
@@ -1175,6 +1218,8 @@ add_action('save_post', 'kg_addPostSave');
1175
if (get_post_meta($post->ID, "_kgflashmediaplayer-thumbtime", true) != "") { $numberofthumbs_value = "1"; }
1176
else { $numberofthumbs_value = "4"; }
1177
1178
if ( get_option('wp_FMP_ffmpeg_exists') == false ) { kg_check_ffmpeg_exists(); } //make sure the new ffmpeg_exists option exists
1179
1180
if ( get_option('wp_FMP_ffmpeg_exists') == "notinstalled" ) { $ffmpeg_disabled_text = 'disabled="disabled" title="FFMPEG not found at '.get_option('wp_FMP_ffmpeg').'"'; }
@@ -1284,15 +1329,15 @@ add_action('save_post', 'kg_addPostSave');
1284
* @param array $attachment
1285
* @return array
1286
*/
1287
- function kg_video_attachment_fields_to_save($post, $attachment) {
1288
- // $attachment part of the form $_POST ($_POST[attachments][postID])
1289
- // $post attachments wp post array - will be saved after returned
1290
- // $post['post_type'] == 'attachment'
1291
- if( isset($attachment['kgflashmediaplayer-poster']) ) {
1292
$uploads = wp_upload_dir();
1293
$posterfile = pathinfo($attachment['kgflashmediaplayer-poster'], PATHINFO_BASENAME);
1294
$tmp_posterpath = $uploads['path'].'/thumb_tmp/'.$posterfile;
1295
- if ( !is_file($uploads['path'].'/'.$posterfile) ) {
1296
if ( is_file($tmp_posterpath) ) {
1297
copy($tmp_posterpath, $uploads['path'].'/'.$posterfile);
1298
$thumb_base = substr($tmp_posterpath, 0, -5);
@@ -1302,28 +1347,27 @@ add_action('save_post', 'kg_addPostSave');
1302
}
1303
if ( is_empty_dir($uploads["path"].'/thumb_tmp') ) { rrmdir($uploads["path"].'/thumb_tmp'); }
1304
}
1305
- update_post_meta($post['ID'], '_kgflashmediaplayer-poster', $attachment['kgflashmediaplayer-poster']);
1306
}
1307
- if( isset($attachment['thumbtime']) ) {update_post_meta($post['ID'], '_kgflashmediaplayer-thumbtime', $attachment['thumbtime']); }
1308
- if( isset($attachment['kgflashmediaplayer-widthsave']) ) { update_post_meta($post['ID'], '_kgflashmediaplayer-width', $attachment['kgflashmediaplayer-widthsave']); }
1309
- if( isset($attachment['kgflashmediaplayer-heightsave']) ) { update_post_meta($post['ID'], '_kgflashmediaplayer-height', $attachment['kgflashmediaplayer-heightsave']); }
1310
- if( isset($attachment['kgflashmediaplayer-aspect']) ) { update_post_meta($post['ID'], '_kgflashmediaplayer-aspect', $attachment['kgflashmediaplayer-aspect']); }
1311
- if( isset($attachment['kgflashmediaplayer-encodemobile']) ) { update_post_meta($post['ID'], '_kgflashmediaplayer-encodemobile', $attachment['kgflashmediaplayer-encodemobile']); }
1312
- if( isset($attachment['kgflashmediaplayer-encodeogg']) ) { update_post_meta($post['ID'], '_kgflashmediaplayer-encodeogg', $attachment['kgflashmediaplayer-encodeogg']); }
1313
- if( isset($attachment['kgflashmediaplayer-encodewebm']) ) { update_post_meta($post['ID'], '_kgflashmediaplayer-encodewebm', $attachment['kgflashmediaplayer-encodewebm']); }
1314
- if( isset($attachment['kgflashmediaplayer-embedsave']) ) { update_post_meta($post['ID'], '_kgflashmediaplayer-embed', $attachment['kgflashmediaplayer-embedsave']); }
1315
- if( isset($attachment['kgflashmediaplayer-downloadsave']) ) { update_post_meta($post['ID'], '_kgflashmediaplayer-download', $attachment['kgflashmediaplayer-downloadsave']); }
1316
- if( isset($attachment['kgflashmediaplayer-showtitlesave']) ) { update_post_meta($post['ID'], '_kgflashmediaplayer-showtitle', $attachment['kgflashmediaplayer-showtitlesave']); }
1317
- if( isset($attachment['kgflashmediaplayer-altembed']) ) { update_post_meta($post['ID'], '_kgflashmediaplayer-altembed', $attachment['kgflashmediaplayer-altembed']); }
1318
- /* if( isset($attachment['kgflashmediaplayer-encoded']) ) { update_post_meta($post['ID'], '_kgflashmediaplayer-encoded', $attachment['kgflashmediaplayer-encoded']); } */
1319
-
1320
- //$attachment_printr = print_r($attachment, true);
1321
- //update_post_meta($post['ID'], '_kgflashmediaplayer-attachment', $attachment_printr );
1322
-
1323
- return $post;
1324
- }
1325
- add_filter("attachment_fields_to_save", "kg_video_attachment_fields_to_save", null, 2);
1326
-
1327
1328
class kgInsertMedia {
1329
//class constructor
@@ -1348,7 +1392,15 @@ class kgInsertMedia {
1348
$attachment['height'] = get_post_meta($attachment_id, "_kgflashmediaplayer-height", true);
1349
$attachment['downloadlink'] = get_post_meta($attachment_id, "_kgflashmediaplayer-download", true);
1350
$attachment['showtitle'] = get_post_meta($attachment_id, "_kgflashmediaplayer-showtitle", true);
1351
- if ($attachment['showtitle'] =="checked") { $output .= '<strong>'.$attachment["title"].'</strong><br />'; }
1352
$output .= '[FMP';
1353
if ($attachment['poster'] !="") { $output .= ' poster="'.$attachment["poster"].'"'; }
1354
if ($attachment['width'] !="") { $output .= ' width="'.$attachment["width"].'"'; }
@@ -1378,108 +1430,111 @@ add_filter('media_upload_tabs', 'kg_embedurl_menu');
1378
1379
function media_embedurl_process() {
1380
1381
- if ( get_option('wp_FMP_ffmpeg_exists') == false ) { kg_check_ffmpeg_exists(); } //make sure the new ffmpeg_exists option exists
1382
-
1383
- if ( get_option('wp_FMP_ffmpeg_exists') == "notinstalled" ) { $ffmpeg_disabled_text = 'disabled="disabled" title="FFMPEG not found at '.get_option('wp_FMP_ffmpeg').'"'; }
1384
- else { $ffmpeg_disabled_text = ""; }
1385
-
1386
- if ( get_option('wp_FMP_encodemobile') == "true" ) { $mobilechecked = "checked"; }
1387
- else { $mobilechecked = ""; }
1388
- if ( get_option('wp_FMP_encodeogg') == "true" ) { $oggchecked = "checked"; }
1389
- else { $oggchecked = ""; }
1390
- if ( get_option('wp_FMP_encodewebm') == "true" ) { $webmchecked = "checked"; }
1391
- else { $webmchecked = ""; }
1392
-
1393
- media_upload_header();
1394
- ?>
1395
- <form class="media-upload-form type-form validate" id="video-form" enctype="multipart/form-data" method="post" action="">
1396
-
1397
- <div id="media-items">
1398
- <div class="media-item media-blank">
1399
- <table id="kgflashmediaplayer-table" class="describe">
1400
- <tbody>
1401
- <tr>
1402
- <th valign="top" scope="row" class="label"><span class="alignleft"><label for="videotitle">Video Title</label></span></th>
1403
- <td class="field"><input type="text" id="videotitle" name="videotitle" value="" size="50" />
1404
- <p class="help"><small>Add an optional header above the video.</small></p></td>
1405
- </tr>
1406
- <tr>
1407
- <th valign="top" scope="row" class="label"><label for="attachments[singleurl][kgflashmediaplayer-url]">Video URL</label></th>
1408
- <td class="field"><input type="text" id="attachments[singleurl][kgflashmediaplayer-url]" name="attachments[singleurl][kgflashmediaplayer-url]" value="" size="50" onchange="document.getElementById('attachments_singleurl_encodeplaceholder').innerHTML = '';"/>
1409
- <p class="help"><small>Specify the URL of the video file.</small></p></td>
1410
- </tr>
1411
- <tr>
1412
- <th valign="top" scope="row" class="label"><span class="alignleft"><label for="numberofthumbs">Thumbnails</label></span></th>
1413
- <td class="field"><div id="attachments_singleurl_thumbnailplaceholder"></div>
1414
- <input id="attachments_singleurl_numberofthumbs" type="text" value="4" maxlength="2" size="4" style="width:25px;" title="Number of Thumbnails" onchange="document.getElementById('attachments[singleurl][thumbtime]').value='';" <?php echo $ffmpeg_disabled_text; ?> />
1415
- <input type="button" id="attachments[singleurl][thumbgenerate]" class="button-secondary" value="Generate" name="thumbgenerate" onclick="kg_generate_thumb('singleurl', 'generate');" <?php echo $ffmpeg_disabled_text; ?> />
1416
- <input type="button" id="thumbrandomize" class="button-secondary" value="Randomize" name="thumbrandomize" onclick="kg_generate_thumb('singleurl', 'random');" <?php echo $ffmpeg_disabled_text; ?> />
1417
- <input type="checkbox" id="attachments_singleurl_firstframe" onchange="document.getElementById('attachments[singleurl][thumbtime]').value ='';" <?php echo $ffmpeg_disabled_text; ?> /><label for="attachments_singleurl_firstframe">Force 1st Frame Thumbnail</label></td>
1418
- </tr>
1419
- <tr>
1420
- <th valign="top" scope="row" class="label"><span class="alignleft"><label for="attachments[singleurl][thumbtime]">Thumbnail Timecode</span></label><br class="clear" /></th>
1421
- <td class="field"><input type="text" name="attachments[singleurl][thumbtime]" id="attachments[singleurl][thumbtime]" value="" size="50" />
1422
- <p class="help"><small>Optional: generates a single thumbnail at the specified time (hh:mm:ss, mm:ss, or s).</small></p></td>
1423
- </tr>
1424
- <tr>
1425
- <th valign="top" scope="row" class="label"><span class="alignleft"><label for="attachments[singleurl][kgflashmediaplayer-poster]">Thumbnail URL</label></span></th>
1426
- <td class="field"><input type="text" name="attachments[singleurl][kgflashmediaplayer-poster]" id="attachments[singleurl][kgflashmediaplayer-poster]" value="" size="50" />
1427
- <p class="help"><small>Leave blank to use <a href="options-general.php?page=video-embed-thumbnail-generator.php" target="_blank">default thumbnail</a>.</small></p></td>
1428
- </tr>
1429
- <tr>
1430
- <th valign="top" scope="row" class="label"><span class="alignleft"><label for="attachments[singleurl][kgflashmediaplayer-width]">Dimensions</label></span></th>
1431
- <td class="field">Width: <input name="attachments_singleurl_kgflashmediaplayer-width" type="text" value="" id="attachments_singleurl_kgflashmediaplayer-width" type="text" style="width:50px;" onchange="kg_set_dimension('singleurl', 'height', this.value);" onkeyup="kg_set_dimension('singleurl', 'height', this.value);"> Height: <input id="attachments_singleurl_kgflashmediaplayer-height" type="text" value="" style="width:50px;" onchange="kg_set_dimension('singleurl', 'width', this.value);" onkeyup="kg_set_dimension('singleurl', 'width', this.value);"> <input type="checkbox" id="attachments_singleurl_kgflashmediaplayer-lockaspect" onclick="kg_set_aspect('singleurl', this.checked);" checked> <label for="attachments_singleurl_kgflashmediaplayer-lockaspect"><small>Lock to Aspect Ratio</small></label>
1432
- <p class="help"><small>Leave blank to use <a href="options-general.php?page=video-embed-thumbnail-generator.php" target="_blank">default dimensions</a>.</small></p></td>
1433
- </tr>
1434
- <tr>
1435
- <th valign="top" scope="row" class="label"><span class="alignleft"><label for="html5">HTML5 & Mobile</span></label></th>
1436
- <td><input type="button" id="html5" class="button-secondary" value="Encode" name="html5" onclick="kg_generate_thumb('singleurl', 'encode');" <?php echo $ffmpeg_disabled_text; ?> />
1437
-
1438
- <input type="checkbox" id="attachments[singleurl][kgflashmediaplayer-encodemobilecheck]" name="attachments[singleurl][kgflashmediaplayer-encodemobilecheck]" value="checked" onclick="if(this.checked) { document.getElementById('attachments[singleurl][kgflashmediaplayer-encodemobile]').value = 'true'; } else { document.getElementById('attachments[singleurl][kgflashmediaplayer-encodemobile]').value = 'false'; }" <?php echo ($mobilechecked." ".$ffmpeg_disabled_text); ?> />
1439
- <label for="attachments[singleurl][kgflashmediaplayer-encodemobilecheck]">Mobile/H.264</label>
1440
-
1441
- <input type="checkbox" id="attachments[singleurl][kgflashmediaplayer-encodewebmcheck]" name="attachments[singleurl][kgflashmediaplayer-encodewebmcheck]" value="checked" onclick="if(this.checked) { document.getElementById('attachments[singleurl][kgflashmediaplayer-encodewebm]').value = 'true'; } else { document.getElementById('attachments[singleurl][kgflashmediaplayer-encodewebm]').value = 'false'; }" <?php echo ($webmchecked." ".$ffmpeg_disabled_text); ?> />
1442
- <label for="attachments[singleurl][kgflashmediaplayer-encodewebmcheck]">WEBM</label>
1443
-
1444
- <input type="checkbox" id="attachments[singleurl][kgflashmediaplayer-encodeoggcheck]" name="attachments[singleurl][kgflashmediaplayer-encodeoggcheck]" value="checked" onclick="if(this.checked) { document.getElementById('attachments[singleurl][kgflashmediaplayer-encodeogg]').value = 'true'; } else { document.getElementById('attachments[singleurl][kgflashmediaplayer-encodeogg]').value = 'false'; }" <?php echo ($oggchecked." ".$ffmpeg_disabled_text); ?> />
1445
- <label for="attachments[singleurl][kgflashmediaplayer-encodeoggcheck]">OGV</label>
1446
-
1447
- <div style="display:inline;" id="attachments_singleurl_altembedselect"></div>
1448
- <div style="display:block;" id="attachments_singleurl_encodeplaceholder"></div>
1449
- <div style="display:block;" id="attachments_singleurl_encodeprogressplaceholder"></div>
1450
-
1451
- <small><em>(Experimental) Generates video files compatible with most mobile & HTML5-compatible browsers.</em></small></td>
1452
- </tr>
1453
- <tr>
1454
- <th valign="top" scope="row" class="label"><span class="alignleft"><label>Options</span></label></th>
1455
- <td><input type="checkbox" name="downloadlink" id="downloadlink" value="true" class="field" /><label for="downloadlink">Generate Download Link Below Video <small>(Makes it easier for users to download video file)</small></label></td>
1456
- </tr>
1457
- <tr class="submit">
1458
- <td></td>
1459
- <td>
1460
- <input type="button" onclick="kg_insert_shortcode();" name="insertonlybutton" id="insertonlybutton" class="button" value="Insert into Post" />
1461
- </td>
1462
- </tr>
1463
- </tbody></table>
1464
- </div>
1465
- </div>
1466
-
1467
- <?php
1468
- $uploads = wp_upload_dir();
1469
- $maxheight = get_option('wp_FMP_height');
1470
- $maxwidth = get_option('wp_FMP_width');
1471
- ?>
1472
-
1473
- <input type='hidden' name='attachments[singleurl][kgflashmediaplayer-security]' id='attachments[singleurl][kgflashmediaplayer-security]' value='<?php echo wp_create_nonce('video-embed-thumbnail-generator-nonce'); ?>' />
1474
- <input type='hidden' name='attachments[singleurl][kgflashmediaplayer-encodemobile]' id='attachments[singleurl][kgflashmediaplayer-encodemobile]' value='<?php echo get_option('wp_FMP_encodemobile'); ?>' />
1475
- <input type='hidden' name='attachments[singleurl][kgflashmediaplayer-encodeogg]' id='attachments[singleurl][kgflashmediaplayer-encodeogg]' value='<?php echo get_option('wp_FMP_encodeogg'); ?>' />
1476
- <input type='hidden' name='attachments[singleurl][kgflashmediaplayer-encodewebm]' id='attachments[singleurl][kgflashmediaplayer-encodewebm]' value='<?php echo get_option('wp_FMP_encodewebm'); ?>' />
1477
- <input type='hidden' name='attachments[singleurl][kgflashmediaplayer-maxheight]' id='attachments[singleurl][kgflashmediaplayer-maxheight]' value='<?php echo($maxheight); ?>' />
1478
- <input type='hidden' name='attachments[singleurl][kgflashmediaplayer-maxwidth]' id='attachments[singleurl][kgflashmediaplayer-maxwidth]' value='<?php echo($maxwidth); ?>' />
1479
- <input type='hidden' name='attachments[singleurl][kgflashmediaplayer-aspect]' id='attachments[singleurl][kgflashmediaplayer-aspect]' value='<?php echo($maxheight/$maxwidth); ?>' />
1480
- </form>
1481
1482
- <?php
1483
} //end media_embedurl_process
1484
1485
function kg_embedurl_handle() {
@@ -1679,7 +1734,6 @@ function enqueue_kg_style() { //loads plugin-related CSS
1679
}
1680
add_action('admin_print_styles', 'enqueue_kg_style');
1681
1682
- add_action('wp_head', 'addSWFObject');
1683
add_action('admin_menu', 'addFMPOptionsPage');
1684
1685
?>
3
Plugin Name: Video Embed & Thumbnail Generator
4
Plugin URI: http://www.kylegilman.net/2011/01/18/video-embed-thumbnail-generator-wordpress-plugin/
5
Description: Generates thumbnails, HTML5-compliant videos, and embed codes for locally hosted videos. Requires FFMPEG for thumbnails and encodes. <a href="options-general.php?page=video-embed-thumbnail-generator.php">Settings</a> | <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=kylegilman@gmail.com&item_name=Video%20Embed%20And%20Thumbnail%20Generator%20Plugin%20Donation/">Donate</a>
6
+ Version: 2.0.6
7
Author: Kyle Gilman
8
Author URI: http://www.kylegilman.net/
9
108
109
function kg_check_ffmpeg_exists() {
110
111
+ $exec_enabled = false;
112
+ $ffmpeg_exists = false;
113
+ $output = array();
114
+ $ffmpeg_path = get_option('wp_FMP_ffmpeg');
115
+ $uploads = wp_upload_dir();
116
117
+ if(function_exists('exec')) {
118
+ $exec_enabled = true;
119
+ exec ( get_option('wp_FMP_ffmpeg').'/ffmpeg -i '.plugins_url("", __FILE__).'/flash/skin/images/PlayNormal.png '.$uploads['path'].'/ffmpeg_exists_test.jpg', $output, $returnvalue );
120
+ }
121
122
+ if ( $exec_enabled == true && file_exists($uploads['path'].'/ffmpeg_exists_test.jpg') ) { //if FFMPEG has executed successfully
123
+ update_option('wp_FMP_ffmpeg_exists', "true");
124
+ $ffmpeg_exists = true;
125
+ unlink($uploads['path'].'/ffmpeg_exists_test.jpg');
126
+ }
127
+ else { update_option('wp_FMP_ffmpeg_exists', "notinstalled"); }
128
129
+ $output_output = implode("/n", $output);
130
131
+ $arr = array ("exec_enabled"=>$exec_enabled, "ffmpeg_exists"=>$ffmpeg_exists, "return_value"=>$returnvalue, "output"=>$output_output);
132
133
+ return $arr;
134
}
135
136
function kg_encodevideo_info($movieurl, $postID) {
248
define("wp_FMP_default_HTML5", "true", true);
249
define("wp_FMP_default_controlbar_style", "docked", true);
250
define("wp_FMP_default_poster", "", true);
251
+ define("wp_FMP_default_endOfVideoOverlay", "", true);
252
define("wp_FMP_default_autohide", "true", true);
253
define("wp_FMP_default_autoplay", "false", true);
254
define("wp_FMP_default_loop", "false", true);
266
define("wp_FMP_default_encodewebm", "true", true);
267
define("wp_FMP_default_vpre", "false", true);
268
define("wp_FMP_default_template", "false", true);
269
+ define("wp_FMP_default_titlecode", "<strong>", true);
270
271
add_option('wp_FMP_swfobject', wp_FMP_swfobject_default);
272
add_option('wp_FMP_flashplayer', wp_FMP_flashplayer_default);
275
add_option('wp_FMP_HTML5', wp_FMP_default_HTML5);
276
add_option('wp_FMP_controlbar_style', wp_FMP_default_controlbar_style);
277
add_option('wp_FMP_poster', wp_FMP_default_poster);
278
+ add_option('wp_FMP_endOfVideoOverlay', wp_FMP_default_endOfVideoOverlay);
279
add_option('wp_FMP_autohide', wp_FMP_default_autohide);
280
add_option('wp_FMP_autoplay', wp_FMP_default_autoplay);
281
add_option('wp_FMP_loop', wp_FMP_default_loop);
293
add_option('wp_FMP_encodewebm', wp_FMP_default_encodewebm);
294
add_option('wp_FMP_vpre', wp_FMP_default_vpre);
295
add_option('wp_FMP_template', wp_FMP_default_template);
296
+ add_option('wp_FMP_titlecode', wp_FMP_default_titlecode);
297
298
kg_check_ffmpeg_exists();
299
300
}
301
register_activation_hook( __FILE__, 'video_embed_thumbnail_generator_activate' );
302
303
function addSWFObject() {
304
if(get_option('wp_FMP_swfobject') == "true") {
305
+ echo "\n<script src=\"".get_bloginfo('wpurl')."/wp-includes/js/swfobject.js\" type=\"text/javascript\"></script>\n";
306
+ //wp_enqueue_script( 'swfobject', , , false );
307
}
308
}
309
+ add_action('wp_head', 'addSWFObject');
310
311
function FMP_shortcode($atts, $content = ''){
312
+
313
+ // workaround for relative video URL (contributed by Lee Fernandes)
314
+ if(substr($content, 0, 1) == '/') $content = get_bloginfo('url').$content;
315
+
316
+ $query_atts = shortcode_atts(
317
+ array('width' => get_option('wp_FMP_width'),
318
+ 'height' => get_option('wp_FMP_height'),
319
+ 'controlbar' => get_option('wp_FMP_controlbar_style'),
320
+ 'autohide' => get_option('wp_FMP_autohide'),
321
+ 'poster' => get_option('wp_FMP_poster'),
322
+ 'endOfVideoOverlay' => get_option('wp_FMP_endOfVideoOverlay'),
323
+ 'endOfVideoOverlaySame' => get_option('wp_FMP_endOfVideoOverlaySame'),
324
+ 'playbutton' => get_option('wp_FMP_playbutton'),
325
+ 'loop' => get_option('wp_FMP_loop'),
326
+ 'autoplay' => get_option('wp_FMP_autoplay'),
327
+ 'streamtype' => get_option('wp_FMP_stream_type'),
328
+ 'scalemode' => get_option('wp_FMP_scale_mode'),
329
+ 'backgroundcolor' => get_option('wp_FMP_bgcolor'),
330
+ 'configuration' => get_option('wp_FMP_configuration'),
331
+ 'skin' => get_option('wp_FMP_skin')), $atts);
332
+
333
+ $div_suffix = substr(uniqid(rand(), true),0,4);
334
+
335
+ global $wpdb;
336
+ $query = "SELECT ID FROM {$wpdb->posts} WHERE guid='$content'";
337
+ $id = $wpdb->get_var($query);
338
+ $moviefiletype = pathinfo(trim($content), PATHINFO_EXTENSION);
339
+ $flashcompatible = array("flv", "f4v", "mp4", "mov", "m4v");
340
+
341
+ if ($id != "") { $encodevideo_info = kg_encodevideo_info(trim($content), $id); }
342
+ else { $encodevideo_info = kg_encodevideo_info(trim($content), 'singleurl'); }
343
+
344
+ $video_swf = plugins_url('', __FILE__)."/flash/StrobeMediaPlayback.swf";
345
+ $minimum_flash = "10.1.0";
346
+
347
+ if ( in_array($moviefiletype, $flashcompatible) ) { $flashvars = "{src:'".urlencode(trim($content))."'"; }
348
+ else { $flashvars = "{src:'".urlencode(trim($encodevideo_info['mobileurl']))."'"; }
349
350
+ if($query_atts["poster"] != '') {
351
+ $flashvars .= ", poster:'".urlencode(trim($query_atts["poster"]))."'";
352
+ }
353
+ if($query_atts["endOfVideoOverlaySame"] == "true") { $query_atts["endOfVideoOverlay"] = $query_atts["poster"]; }
354
+ if($query_atts["endOfVideoOverlay"] != '') {
355
+ $flashvars .= ", endOfVideoOverlay:'".urlencode(trim($query_atts["endOfVideoOverlay"]))."'";
356
+ }
357
+ if($query_atts["controlbar"] != '') {
358
+ $flashvars .= ", controlBarMode:'".$query_atts["controlbar"]."'";
359
+ }
360
+ if($query_atts["autohide"] != '') {
361
+ $flashvars .= ", controlBarAutoHide:'".$query_atts["autohide"]."'";
362
+ }
363
+ if($query_atts["playbutton"] != '') {
364
+ $flashvars .= ", playButtonOverlay:'".$query_atts["playbutton"]."'";
365
+ }
366
+ if($query_atts["loop"] != '') {
367
+ $flashvars .= ", loop:'".$query_atts["loop"]."'";
368
+ }
369
+ if($query_atts["autoplay"] != '') {
370
+ $flashvars .= ", autoPlay:'".$query_atts["autoplay"]."'";
371
+ }
372
+ if($query_atts["streamtype"] != '') {
373
+ $flashvars .= ", streamType:'".$query_atts["streamtype"]."'";
374
+ }
375
+ if($query_atts["scalemode"] != '') {
376
+ $flashvars .= ", scaleMode:'".$query_atts["scalemode"]."'";
377
+ }
378
+ if($query_atts["backgroundcolor"] != '') {
379
+ $flashvars .= ", backgroundColor:'".$query_atts["backgroundcolor"]."'";
380
+ }
381
+ if($query_atts["configuration"] != '') {
382
+ $flashvars .= ", configuration:'".urlencode($query_atts["configuration"])."'";
383
+ }
384
+ if($query_atts["skin"] != '') {
385
+ $flashvars .= ", skin:'".urlencode($query_atts["skin"])."'";
386
+ }
387
+ $flashvars .= ", verbose:'true'";
388
+ $flashvars .= "}";
389
390
+ $params = "{allowfullscreen:'true', allowscriptaccess:'always', base:'".plugins_url("", __FILE__)."/flash/'}";
391
392
+ if(get_option('wp_FMP_HTML5') == "true") {
393
+ include_once dirname( __FILE__ ) .'/mdetect.php';
394
+ $uagent_obj = new uagent_info();
395
+ $isAndroid = $uagent_obj->DetectAndroid(); //determine if we're running on an Android device
396
+ $isTierIphone = $uagent_obj->DetectTierIphone(); //determine if we're running on a mobile device that plays iPhone-optimized video
397
+ $moviefilebasename = pathinfo(trim($content), PATHINFO_FILENAME);
398
+ $h264compatible = array("mp4", "mov", "m4v");
399
400
+ $code = "<div id=\"flashcontent".$div_suffix."\">";
401
+ $code .= "<video ";
402
+ if ($query_atts["loop"] == 'true') { $code .= "loop='loop' " ;}
403
+ if ($query_atts["autoplay"] == 'true') { $code .= "autoplay='autoplay' " ;}
404
+ if ($query_atts["controlbar"] != 'none') { $code .= "controls='controls' " ;}
405
+ if ($isAndroid) { $code .= "onclick='this.play();' "; }
406
+ $code .= "preload='metadata' ";
407
+ if($query_atts["poster"] != '' && !$isAndroid) {
408
+ $code .= "poster='".$query_atts["poster"]."' ";
409
}
410
+ if($query_atts["poster"] != '' && $isAndroid) {
411
+ $code .= "poster='".plugins_url('', __FILE__)."/images/androidthumb.php?src=".$query_atts["poster"]."' ";
412
+ }
413
+ $code .= "width='".$query_atts["width"]."' height='".$query_atts["height"]."'";
414
+ $code .= ">\n";
415
+
416
+ if ( in_array($moviefiletype, $h264compatible) ) {
417
+ if ( $encodevideo_info["mobile_exists"] && $isTierIphone ) {
418
$code .= "<source src='".$encodevideo_info["mobileurl"]."'";
419
}
420
+ else { $code .= "<source src='".trim($content)."'"; }
421
+ if (!$isAndroid) { $code.= " type='video/mp4'"; }
422
+ $code .=">\n";
423
}
424
+ else { if ( $encodevideo_info["mobile_exists"] ) {
425
+ $code .= "<source src='".$encodevideo_info["mobileurl"]."'";
426
+ if (!$isAndroid) { $code.= " type='video/mp4'"; }
427
+ $code .=">\n";
428
+ } }
429
+ if ( $encodevideo_info["webm_exists"] ) { $code .= "<source src='".$encodevideo_info["webmurl"]."' type='video/webm'>\n"; }
430
+ if ( $encodevideo_info["ogg_exists"] ) { $code .= "<source src='".$encodevideo_info["oggurl"]."' type='video/ogg'>\n"; }
431
+ if ( !in_array($moviefiletype, $flashcompatible) && $encodevideo_info["mobile_exists"] ) { // Flash fallback if WEBM/OGV embed
432
+ $flashvars_remove = array("{", "}", "'");
433
+ $flashvars_reformat = str_replace($flashvars_remove, "", $flashvars);
434
+ $flashvars_reformat = str_replace(":", "=", $flashvars_reformat);
435
+ $flashvars_reformat = str_replace(", ", "&", $flashvars_reformat);
436
+ $code .= '<object width="'.trim($query_atts["width"]).'" height="'.trim($query_atts["height"]).'" type="application/x-shockwave-flash" data="'.$video_swf.'">'."\n";
437
+ $code .= '<param name="movie" value="'.$video_swf.'" /></param>'."\n";
438
+ $code .= '<param name="flashvars" value="'.$flashvars_reformat.'" /></param>'."\n";
439
+ $code .= '<param name="base" value="'.plugins_url('', __FILE__).'/flash/" /></param>'."\n";
440
+ $code .= '<param name="allowFullScreen" value="true" /></param>'."\n";
441
+ $code .= '<param name="allowscriptaccess" value="always" /></param>'."\n";
442
+ $code .= '</object>';
443
}
444
+ $code .= "</video>\n";
445
+ $code .= "</div>\n\n";
446
+
447
+ /* if ($id !="") {
448
+ $iframeurl = site_url('/')."?attachment_id=".$id;
449
+ $iframecode = '<iframe src="'.$iframeurl.'" frameborder="0" scrolling="no" width="'.$query_atts['width'].'" height="'.$query_atts["height"].'"></iframe>';
450
+ $code .= "<div style='background-color:#e8e8e8; width:".$query_atts['width']."px; height:25px; margin-top:-25px; padding:5px; font-size:8pt;'>Embed code: <input style='height:10px; background-color:#f4f4f4;' type='text' value='".$iframecode."' width='10' onClick='this.select();'></div>\n";
451
+ } */
452
+ } else {
453
+ if ( in_array($moviefiletype, $flashcompatible) ) { $code = "<div id=\"flashcontent".$div_suffix."\">".get_option('wp_FMP_flashplayer')."</div>\n\n"; }
454
+ }
455
+
456
+ if ( in_array($moviefiletype, $flashcompatible) ) {
457
+ $code .= "<script type=\"text/javascript\">\n\t";
458
+ $code .= "swfobject.embedSWF('".$video_swf."', 'flashcontent".$div_suffix."', '".trim($query_atts['width'])."', '".trim($query_atts['height'])."', '".$minimum_flash."', '".plugins_url("", __FILE__)."/flash/expressInstall.swf', $flashvars, $params)\n";
459
+ $code .= "</script>\n";
460
+ }
461
462
+ return $code;
463
}
464
add_shortcode('FMP', 'FMP_shortcode');
465
466
function addFMPOptionsPage() {
467
+ add_options_page('Video Embed & Thumbnail Generator', 'Video Embed & Thumbnail Generator', 'administrator', basename(__FILE__), 'FMPOptionsPage');
468
+ }
469
470
function FMPOptionsPage() {
471
472
+ define("wp_FMP_swfobject_default", "true", true);
473
+ define("wp_FMP_flashplayer_default", "<strong>Please upgrade Flash Player</strong> This content is shown when the user does not have a correct Flash Player version installed.", true);
474
+ define("wp_FMP_default_width", "640", true);
475
+ define("wp_FMP_default_height", "360", true);
476
+ define("wp_FMP_default_HTML5", "true", true);
477
+ define("wp_FMP_default_controlbar_style", "docked", true);
478
+ define("wp_FMP_default_poster", "", true);
479
+ define("wp_FMP_default_endOfVideoOverlay", "", true);
480
+ define("wp_FMP_default_autohide", "true", true);
481
+ define("wp_FMP_default_autoplay", "false", true);
482
+ define("wp_FMP_default_loop", "false", true);
483
+ define("wp_FMP_default_playbutton", "true", true);
484
+ define("wp_FMP_default_stream_type", "liveOrRecorded", true);
485
+ define("wp_FMP_default_scale_mode", "letterbox", true);
486
+ define("wp_FMP_default_bgcolor", "", true);
487
+ define("wp_FMP_default_configuration", "", true);
488
+ define("wp_FMP_default_skin", plugins_url("", __FILE__)."/flash/skin/kg_skin.xml", true);
489
+ define("wp_FMP_default_ffmpeg", "/usr/local/bin", true);
490
+ define("wp_FMP_default_mobile_res", "480", true);
491
+ define("wp_FMP_default_encodemobile", "true", true);
492
+ define("wp_FMP_default_encodeogg", "false", true);
493
+ define("wp_FMP_default_encodewebm", "true", true);
494
+ define("wp_FMP_default_vpre", "false", true);
495
+ define("wp_FMP_default_template", "false", true);
496
+ define("wp_FMP_default_titlecode", "<strong>", true);
497
+
498
+ if (isset($_POST['wp_FMP_reset'])) {
499
+ update_option('wp_FMP_swfobject', wp_FMP_swfobject_default);
500
+ update_option('wp_FMP_HTML5', wp_FMP_default_HTML5);
501
+ update_option('wp_FMP_width', wp_FMP_default_width);
502
+ update_option('wp_FMP_height', wp_FMP_default_height);
503
+ update_option('wp_FMP_flashplayer', wp_FMP_flashplayer_default);
504
+ update_option('wp_FMP_controlbar_style', wp_FMP_default_controlbar_style);
505
+ update_option('wp_FMP_poster', wp_FMP_default_poster);
506
+ update_option('wp_FMP_endOfVideoOverlay', wp_FMP_default_endOfVideoOverlay);
507
+ update_option('wp_FMP_autohide', wp_FMP_default_autohide);
508
+ update_option('wp_FMP_autoplay', wp_FMP_default_autoplay);
509
+ update_option('wp_FMP_loop', wp_FMP_default_loop);
510
+ update_option('wp_FMP_playbutton', wp_FMP_default_playbutton);
511
+ update_option('wp_FMP_stream_type', wp_FMP_default_stream_type);
512
+ update_option('wp_FMP_scale_mode', wp_FMP_default_scale_mode);
513
+ update_option('wp_FMP_bgcolor', wp_FMP_default_bgcolor);
514
+ update_option('wp_FMP_configuration', wp_FMP_default_configuration);
515
+ update_option('wp_FMP_skin', wp_FMP_default_skin);
516
+ update_option('wp_FMP_ffmpeg', wp_FMP_default_ffmpeg);
517
+ update_option('wp_FMP_mobile_res', wp_FMP_default_mobile_res);
518
+ update_option('wp_FMP_encodemobile', wp_FMP_default_encodemobile);
519
+ update_option('wp_FMP_encodeogg', wp_FMP_default_encodeogg);
520
+ update_option('wp_FMP_encodewebm', wp_FMP_default_encodewebm);
521
+ update_option('wp_FMP_vpre', wp_FMP_default_vpre);
522
+ update_option('wp_FMP_template', wp_FMP_default_template);
523
+ update_option('wp_FMP_titlecode', wp_FMP_default_titlecode);
524
+
525
+ echo "<div class='updated'><p><strong>Video Embed & Thumbnail Generator plugin reset to default settings</strong></p></div>";
526
527
+ $ffmpeg_info = kg_check_ffmpeg_exists();
528
529
+ if ( $ffmpeg_info['exec_enabled'] == false ) {
530
+ echo "<div class='error'><p><strong>EXEC function is disabled in PHP settings. Embed codes will work, but video thumbnail generation and Mobile/HTML5 encoding will not. Contact your System Administrator to find out if you can enable EXEC</strong></p></div>";
531
+ }
532
+ elseif ( $ffmpeg_info['ffmpeg_exists'] == false ) {
533
+ echo "<div class='error'><p><strong>FFMPEG not found at ".get_option('wp_FMP_ffmpeg').". Embed codes will work, but video thumbnail generation and Mobile/HTML5 encoding will not.</strong></p></div>";
534
+ }
535
536
+ }
537
538
+ if (isset($_POST['wp_FMP_update'])) {
539
+ check_admin_referer();
540
+ $use_swfobject = $_POST[wp_FMP_swfobject];
541
+ $use_html5fallback = $_POST[wp_FMP_HTML5];
542
+ $use_autohide = $_POST[wp_FMP_autohide];
543
+ $use_autoplay = $_POST[wp_FMP_autoplay];
544
+ $use_loop = $_POST[wp_FMP_loop];
545
+ $use_playbutton = $_POST[wp_FMP_playbutton];
546
+ $use_encodemobile = $_POST[wp_FMP_encodemobile];
547
+ $use_encodeogg = $_POST[wp_FMP_encodeogg];
548
+ $use_encodewebm = $_POST[wp_FMP_encodewebm];
549
+ $use_vpre = $_POST[wp_FMP_vpre];
550
+ $use_template = $_POST[wp_FMP_template];
551
+ $use_endOfVideoOverlaySame = $_POST[wp_FMP_endOfVideoOverlaySame];
552
+
553
+ if ($use_swfobject == 'use') {
554
+ update_option(wp_FMP_swfobject, "true");
555
+ } else {
556
+ update_option(wp_FMP_swfobject, "false");
557
+ }
558
+
559
+ if ($use_html5fallback == 'use') {
560
+ update_option(wp_FMP_HTML5, "true");
561
+ } else {
562
+ update_option(wp_FMP_HTML5, "false");
563
+ }
564
+
565
+ if ($use_autohide == 'use') {
566
+ update_option(wp_FMP_autohide, "true");
567
+ } else {
568
+ update_option(wp_FMP_autohide, "false");
569
+ }
570
571
+ if ($use_autoplay == 'use') {
572
+ update_option(wp_FMP_autoplay, "true");
573
+ } else {
574
+ update_option(wp_FMP_autoplay, "false");
575
+ }
576
+
577
+ if ($use_loop == 'use') {
578
+ update_option(wp_FMP_loop, "true");
579
+ } else {
580
+ update_option(wp_FMP_loop, "false");
581
+ }
582
583
+ if ($use_playbutton == 'use') {
584
+ update_option(wp_FMP_playbutton, "true");
585
+ } else {
586
+ update_option(wp_FMP_playbutton, "false");
587
+ }
588
589
+ if ($use_encodemobile == 'use') {
590
+ update_option(wp_FMP_encodemobile, "true");
591
+ } else {
592
+ update_option(wp_FMP_encodemobile, "false");
593
+ }
594
595
+ if ($use_encodeogg == 'use') {
596
+ update_option(wp_FMP_encodeogg, "true");
597
+ } else {
598
+ update_option(wp_FMP_encodeogg, "false");
599
+ }
600
601
+ if ($use_encodewebm == 'use') {
602
+ update_option(wp_FMP_encodewebm, "true");
603
+ } else {
604
+ update_option(wp_FMP_encodewebm, "false");
605
+ }
606
607
+ if ($use_vpre == 'use') {
608
+ update_option(wp_FMP_vpre, "true");
609
+ } else {
610
+ update_option(wp_FMP_vpre, "false");
611
+ }
612
613
+ if ($use_template == 'use') {
614
+ update_option(wp_FMP_template, "true");
615
+ } else {
616
+ update_option(wp_FMP_template, "false");
617
+ }
618
619
+ if ($use_endOfVideoOverlaySame == 'use') {
620
+ update_option(wp_FMP_endOfVideoOverlaySame, "true");
621
+ } else {
622
+ update_option(wp_FMP_endOfVideoOverlaySame, "false");
623
+ }
624
625
+ update_option('wp_FMP_mobile_res', $_POST[wp_FMP_mobile_res]);
626
+ update_option('wp_FMP_width', $_POST[wp_FMP_width]);
627
+ update_option('wp_FMP_height', $_POST[wp_FMP_height]);
628
+ update_option('wp_FMP_bgcolor', $_POST[wp_FMP_bgcolor]);
629
+ update_option('wp_FMP_configuration', $_POST[wp_FMP_configuration]);
630
+ update_option('wp_FMP_skin', $_POST[wp_FMP_skin]);
631
+ update_option('wp_FMP_flashplayer', $_POST[wp_FMP_flashplayer]);
632
+ update_option('wp_FMP_controlbar_style', $_POST[wp_FMP_controlbar_style]);
633
+ update_option('wp_FMP_stream_type', $_POST[wp_FMP_stream_type]);
634
+ update_option('wp_FMP_scale_mode', $_POST[wp_FMP_scale_mode]);
635
+ update_option('wp_FMP_poster', $_POST[wp_FMP_poster]);
636
+ update_option('wp_FMP_endOfVideoOverlay', $_POST[wp_FMP_endOfVideoOverlay]);
637
+ update_option('wp_FMP_ffmpeg', $_POST[wp_FMP_ffmpeg]);
638
+ update_option('wp_FMP_titlecode', $_POST[wp_FMP_titlecode]);
639
+
640
+ echo "<div class='updated'><p><strong>Video Embed & Thumbnail Generator plugin settings updated</strong></p></div>";
641
+
642
+ $ffmpeg_info = kg_check_ffmpeg_exists();
643
+
644
+ if ( $ffmpeg_info['exec_enabled'] == false ) {
645
+ echo "<div class='error'><p><strong>EXEC function is disabled in PHP settings. Embed codes will work, but video thumbnail generation and Mobile/HTML5 encoding will not. Contact your System Administrator to find out if you can enable EXEC</strong></p></div>";
646
+ }
647
+ elseif ( $ffmpeg_info['ffmpeg_exists'] == false ) {
648
+ echo "<div class='error'><p><strong>FFMPEG not found at ".get_option('wp_FMP_ffmpeg').". Embed codes will work, but video thumbnail generation and Mobile/HTML5 encoding will not.</strong></p></div>";
649
}
650
+ }
651
652
?>
653
776
</th>
777
<td width="10"></td>
778
<td>
779
+ <input name="wp_FMP_ffmpeg" id="wp_FMP_ffmpeg" type="text" value="<?php echo stripslashes(get_option('wp_FMP_ffmpeg')); ?>" /><br />
780
<em>Don't include trailing slash. Example: /usr/local/bin</em>
781
</td>
782
</tr>
797
<em><small>Check this if your installed version of FFMPEG is old enough that libx264 requires vpre flags to operate (Dreamhost users must turn this on).<br />This should help if you can encode WEBM or OGV files but H264/Mobile files fail. It will cause newer versions of FFMPEG to fail and probably won't work on Windows servers.</em></small>
798
</td>
799
</tr>
800
+ <tr>
801
+ <th scope="row" valign="top" align="left">
802
+ <label>Video Title Text HTML Formatting:</label>
803
+ </th>
804
+ <td width="10"></td>
805
+ <td>
806
+ <input name="wp_FMP_titlecode" id="wp_FMP_titlecode" type="text" value="<?php echo htmlentities(stripslashes(get_option('wp_FMP_titlecode'))); ?>" /><br />
807
+ <em><small>HTML tag applied to video titles inserted by the plugin. Ex: &lt;strong&gt;, &lt;em&gt;, &lt;H2&gt;, &lt;span class="videotitle"&gt;.<br /> Corresponding closing tags will be applied to the end of the title automatically.</em></small>
808
+ </td>
809
+ </tr>
810
<tr>
811
<th scope="row" valign="top" align="left">
812
<label>Flash Player not installed message:</label>
813
</th>
814
<td width="10"></td>
815
<td>
816
+ <textarea name="wp_FMP_flashplayer" id="wp_FMP_flashplayer" rows="5" cols="50"><?php echo get_option('wp_FMP_flashplayer'); ?></textarea><br />
817
<em>This message will only be shown if HTML5 video fallback is disabled</em>
818
</td>
819
</tr>
917
<tr>
918
<th colspan="3"><h4>The following options will only affect Flash playback</h4></th><td>
919
</td>
920
+ </tr>
921
+ <tr>
922
+ <th scope="row" valign="top" align="left">
923
+ <label>End of video image:</label>
924
+ </th>
925
+ <td width="10"></td>
926
+ <td>
927
+ <input type='checkbox' name='wp_FMP_endOfVideoOverlaySame' id='wp_FMP_endOfVideoOverlaySame' value='use' onclick='if (this.checked == true) { document.getElementById("wp_FMP_endOfVideoOverlay").disabled=true; } else { document.getElementById("wp_FMP_endOfVideoOverlay").disabled=false; }' <?php if(get_option('wp_FMP_endOfVideoOverlaySame') == "true") { echo "checked"; } echo " /> Display poster image again when video ends.<br />"; ?>
928
+ <input type='text' name='wp_FMP_endOfVideoOverlay' id='wp_FMP_endOfVideoOverlay' size='50' value='<?php echo get_option('wp_FMP_endOfVideoOverlay'); ?>' <?php if(get_option('wp_FMP_endOfVideoOverlaySame') == "true") { echo "disabled"; } ?> /> Display alternate image when video ends.<br />
929
+ <small><em>Leave blank to display the first frame of the video when video ends.</em></small>
930
+ </td>
931
+ </tr>
932
<tr>
933
<th scope="row" valign="top" align="left">
934
<label>Default background color:</label>
1218
if (get_post_meta($post->ID, "_kgflashmediaplayer-thumbtime", true) != "") { $numberofthumbs_value = "1"; }
1219
else { $numberofthumbs_value = "4"; }
1220
1221
+ if ( get_option('wp_FMP_titlecode') === false ) { update_option('wp_FMP_titlecode', '<strong>'); }
1222
+
1223
if ( get_option('wp_FMP_ffmpeg_exists') == false ) { kg_check_ffmpeg_exists(); } //make sure the new ffmpeg_exists option exists
1224
1225
if ( get_option('wp_FMP_ffmpeg_exists') == "notinstalled" ) { $ffmpeg_disabled_text = 'disabled="disabled" title="FFMPEG not found at '.get_option('wp_FMP_ffmpeg').'"'; }
1329
* @param array $attachment
1330
* @return array
1331
*/
1332
+ function kg_video_attachment_fields_to_save($post, $attachment) {
1333
+ // $attachment part of the form $_POST ($_POST[attachments][postID])
1334
+ // $post attachments wp post array - will be saved after returned
1335
+ // $post['post_type'] == 'attachment'
1336
+ if( isset($attachment['kgflashmediaplayer-poster']) ) {
1337
$uploads = wp_upload_dir();
1338
$posterfile = pathinfo($attachment['kgflashmediaplayer-poster'], PATHINFO_BASENAME);
1339
$tmp_posterpath = $uploads['path'].'/thumb_tmp/'.$posterfile;
1340
+ if ( !is_file($uploads['path'].'/'.$posterfile) ) {
1341
if ( is_file($tmp_posterpath) ) {
1342
copy($tmp_posterpath, $uploads['path'].'/'.$posterfile);
1343
$thumb_base = substr($tmp_posterpath, 0, -5);
1347
}
1348
if ( is_empty_dir($uploads["path"].'/thumb_tmp') ) { rrmdir($uploads["path"].'/thumb_tmp'); }
1349
}
1350
+ update_post_meta($post['ID'], '_kgflashmediaplayer-poster', $attachment['kgflashmediaplayer-poster']);
1351
}
1352
+ if( isset($attachment['thumbtime']) ) {update_post_meta($post['ID'], '_kgflashmediaplayer-thumbtime', $attachment['thumbtime']); }
1353
+ if( isset($attachment['kgflashmediaplayer-widthsave']) ) { update_post_meta($post['ID'], '_kgflashmediaplayer-width', $attachment['kgflashmediaplayer-widthsave']); }
1354
+ if( isset($attachment['kgflashmediaplayer-heightsave']) ) { update_post_meta($post['ID'], '_kgflashmediaplayer-height', $attachment['kgflashmediaplayer-heightsave']); }
1355
+ if( isset($attachment['kgflashmediaplayer-aspect']) ) { update_post_meta($post['ID'], '_kgflashmediaplayer-aspect', $attachment['kgflashmediaplayer-aspect']); }
1356
+ if( isset($attachment['kgflashmediaplayer-encodemobile']) ) { update_post_meta($post['ID'], '_kgflashmediaplayer-encodemobile', $attachment['kgflashmediaplayer-encodemobile']); }
1357
+ if( isset($attachment['kgflashmediaplayer-encodeogg']) ) { update_post_meta($post['ID'], '_kgflashmediaplayer-encodeogg', $attachment['kgflashmediaplayer-encodeogg']); }
1358
+ if( isset($attachment['kgflashmediaplayer-encodewebm']) ) { update_post_meta($post['ID'], '_kgflashmediaplayer-encodewebm', $attachment['kgflashmediaplayer-encodewebm']); }
1359
+ if( isset($attachment['kgflashmediaplayer-embedsave']) ) { update_post_meta($post['ID'], '_kgflashmediaplayer-embed', $attachment['kgflashmediaplayer-embedsave']); }
1360
+ if( isset($attachment['kgflashmediaplayer-downloadsave']) ) { update_post_meta($post['ID'], '_kgflashmediaplayer-download', $attachment['kgflashmediaplayer-downloadsave']); }
1361
+ if( isset($attachment['kgflashmediaplayer-showtitlesave']) ) { update_post_meta($post['ID'], '_kgflashmediaplayer-showtitle', $attachment['kgflashmediaplayer-showtitlesave']); }
1362
+ if( isset($attachment['kgflashmediaplayer-altembed']) ) { update_post_meta($post['ID'], '_kgflashmediaplayer-altembed', $attachment['kgflashmediaplayer-altembed']); }
1363
+ /* if( isset($attachment['kgflashmediaplayer-encoded']) ) { update_post_meta($post['ID'], '_kgflashmediaplayer-encoded', $attachment['kgflashmediaplayer-encoded']); } */
1364
+
1365
+ //$attachment_printr = print_r($attachment, true);
1366
+ //update_post_meta($post['ID'], '_kgflashmediaplayer-attachment', $attachment_printr );
1367
+
1368
+ return $post;
1369
+ }
1370
+ add_filter("attachment_fields_to_save", "kg_video_attachment_fields_to_save", null, 2);
1371
1372
class kgInsertMedia {
1373
//class constructor
1392
$attachment['height'] = get_post_meta($attachment_id, "_kgflashmediaplayer-height", true);
1393
$attachment['downloadlink'] = get_post_meta($attachment_id, "_kgflashmediaplayer-download", true);
1394
$attachment['showtitle'] = get_post_meta($attachment_id, "_kgflashmediaplayer-showtitle", true);
1395
+ if ($attachment['showtitle'] =="checked") {
1396
+ $titlecode = html_entity_decode(stripslashes(get_option('wp_FMP_titlecode')));
1397
+ if ( substr($titlecode, 0, 1) != '<' ) { $titlecode = '<'.$titlecode; }
1398
+ if ( substr($titlecode, -1, 1) != '>' ) { $titlecode .= '>'; }
1399
+ $endtitlecode = str_replace("<", "</", $titlecode);
1400
+ $endtitlecode_array = explode(' ', $endtitlecode);
1401
+ if ( substr($endtitlecode_array[0], -1) != ">" ) { $endtitlecode = $endtitlecode_array[0].">"; }
1402
+ $output .= $titlecode.$attachment["title"].$endtitlecode.'<br />';
1403
+ }
1404
$output .= '[FMP';
1405
if ($attachment['poster'] !="") { $output .= ' poster="'.$attachment["poster"].'"'; }
1406
if ($attachment['width'] !="") { $output .= ' width="'.$attachment["width"].'"'; }
1430
1431
function media_embedurl_process() {
1432
1433
+ if ( get_option('wp_FMP_titlecode') === false ) { update_option('wp_FMP_titlecode', '<strong>'); }
1434
1435
+ if ( get_option('wp_FMP_ffmpeg_exists') == false ) { kg_check_ffmpeg_exists(); } //make sure the new ffmpeg_exists option exists
1436
+
1437
+ if ( get_option('wp_FMP_ffmpeg_exists') == "notinstalled" ) { $ffmpeg_disabled_text = 'disabled="disabled" title="FFMPEG not found at '.get_option('wp_FMP_ffmpeg').'"'; }
1438
+ else { $ffmpeg_disabled_text = ""; }
1439
+
1440
+ if ( get_option('wp_FMP_encodemobile') == "true" ) { $mobilechecked = "checked"; }
1441
+ else { $mobilechecked = ""; }
1442
+ if ( get_option('wp_FMP_encodeogg') == "true" ) { $oggchecked = "checked"; }
1443
+ else { $oggchecked = ""; }
1444
+ if ( get_option('wp_FMP_encodewebm') == "true" ) { $webmchecked = "checked"; }
1445
+ else { $webmchecked = ""; }
1446
+
1447
+ media_upload_header();
1448
+ ?>
1449
+ <form class="media-upload-form type-form validate" id="video-form" enctype="multipart/form-data" method="post" action="">
1450
+
1451
+ <div id="media-items">
1452
+ <div class="media-item media-blank">
1453
+ <table id="kgflashmediaplayer-table" class="describe">
1454
+ <tbody>
1455
+ <tr>
1456
+ <th valign="top" scope="row" class="label"><span class="alignleft"><label for="videotitle">Video Title</label></span></th>
1457
+ <td class="field"><input type="text" id="videotitle" name="videotitle" value="" size="50" />
1458
+ <p class="help"><small>Add an optional header above the video.</small></p></td>
1459
+ </tr>
1460
+ <tr>
1461
+ <th valign="top" scope="row" class="label"><label for="attachments[singleurl][kgflashmediaplayer-url]">Video URL</label></th>
1462
+ <td class="field"><input type="text" id="attachments[singleurl][kgflashmediaplayer-url]" name="attachments[singleurl][kgflashmediaplayer-url]" value="" size="50" onchange="document.getElementById('attachments_singleurl_encodeplaceholder').innerHTML = '';"/>
1463
+ <p class="help"><small>Specify the URL of the video file.</small></p></td>
1464
+ </tr>
1465
+ <tr>
1466
+ <th valign="top" scope="row" class="label"><span class="alignleft"><label for="numberofthumbs">Thumbnails</label></span></th>
1467
+ <td class="field"><div id="attachments_singleurl_thumbnailplaceholder"></div>
1468
+ <input id="attachments_singleurl_numberofthumbs" type="text" value="4" maxlength="2" size="4" style="width:25px;" title="Number of Thumbnails" onchange="document.getElementById('attachments[singleurl][thumbtime]').value='';" <?php echo $ffmpeg_disabled_text; ?> />
1469
+ <input type="button" id="attachments[singleurl][thumbgenerate]" class="button-secondary" value="Generate" name="thumbgenerate" onclick="kg_generate_thumb('singleurl', 'generate');" <?php echo $ffmpeg_disabled_text; ?> />
1470
+ <input type="button" id="thumbrandomize" class="button-secondary" value="Randomize" name="thumbrandomize" onclick="kg_generate_thumb('singleurl', 'random');" <?php echo $ffmpeg_disabled_text; ?> />
1471
+ <input type="checkbox" id="attachments_singleurl_firstframe" onchange="document.getElementById('attachments[singleurl][thumbtime]').value ='';" <?php echo $ffmpeg_disabled_text; ?> /><label for="attachments_singleurl_firstframe">Force 1st Frame Thumbnail</label></td>
1472
+ </tr>
1473
+ <tr>
1474
+ <th valign="top" scope="row" class="label"><span class="alignleft"><label for="attachments[singleurl][thumbtime]">Thumbnail Timecode</span></label><br class="clear" /></th>
1475
+ <td class="field"><input type="text" name="attachments[singleurl][thumbtime]" id="attachments[singleurl][thumbtime]" value="" size="50" />
1476
+ <p class="help"><small>Optional: generates a single thumbnail at the specified time (hh:mm:ss, mm:ss, or s).</small></p></td>
1477
+ </tr>
1478
+ <tr>
1479
+ <th valign="top" scope="row" class="label"><span class="alignleft"><label for="attachments[singleurl][kgflashmediaplayer-poster]">Thumbnail URL</label></span></th>
1480
+ <td class="field"><input type="text" name="attachments[singleurl][kgflashmediaplayer-poster]" id="attachments[singleurl][kgflashmediaplayer-poster]" value="" size="50" />
1481
+ <p class="help"><small>Leave blank to use <a href="options-general.php?page=video-embed-thumbnail-generator.php" target="_blank">default thumbnail</a>.</small></p></td>
1482
+ </tr>
1483
+ <tr>
1484
+ <th valign="top" scope="row" class="label"><span class="alignleft"><label for="attachments[singleurl][kgflashmediaplayer-width]">Dimensions</label></span></th>
1485
+ <td class="field">Width: <input name="attachments_singleurl_kgflashmediaplayer-width" type="text" value="" id="attachments_singleurl_kgflashmediaplayer-width" type="text" style="width:50px;" onchange="kg_set_dimension('singleurl', 'height', this.value);" onkeyup="kg_set_dimension('singleurl', 'height', this.value);"> Height: <input id="attachments_singleurl_kgflashmediaplayer-height" type="text" value="" style="width:50px;" onchange="kg_set_dimension('singleurl', 'width', this.value);" onkeyup="kg_set_dimension('singleurl', 'width', this.value);"> <input type="checkbox" id="attachments_singleurl_kgflashmediaplayer-lockaspect" onclick="kg_set_aspect('singleurl', this.checked);" checked> <label for="attachments_singleurl_kgflashmediaplayer-lockaspect"><small>Lock to Aspect Ratio</small></label>
1486
+ <p class="help"><small>Leave blank to use <a href="options-general.php?page=video-embed-thumbnail-generator.php" target="_blank">default dimensions</a>.</small></p></td>
1487
+ </tr>
1488
+ <tr>
1489
+ <th valign="top" scope="row" class="label"><span class="alignleft"><label for="html5">HTML5 & Mobile</span></label></th>
1490
+ <td><input type="button" id="html5" class="button-secondary" value="Encode" name="html5" onclick="kg_generate_thumb('singleurl', 'encode');" <?php echo $ffmpeg_disabled_text; ?> />
1491
+
1492
+ <input type="checkbox" id="attachments[singleurl][kgflashmediaplayer-encodemobilecheck]" name="attachments[singleurl][kgflashmediaplayer-encodemobilecheck]" value="checked" onclick="if(this.checked) { document.getElementById('attachments[singleurl][kgflashmediaplayer-encodemobile]').value = 'true'; } else { document.getElementById('attachments[singleurl][kgflashmediaplayer-encodemobile]').value = 'false'; }" <?php echo ($mobilechecked." ".$ffmpeg_disabled_text); ?> />
1493
+ <label for="attachments[singleurl][kgflashmediaplayer-encodemobilecheck]">Mobile/H.264</label>
1494
+
1495
+ <input type="checkbox" id="attachments[singleurl][kgflashmediaplayer-encodewebmcheck]" name="attachments[singleurl][kgflashmediaplayer-encodewebmcheck]" value="checked" onclick="if(this.checked) { document.getElementById('attachments[singleurl][kgflashmediaplayer-encodewebm]').value = 'true'; } else { document.getElementById('attachments[singleurl][kgflashmediaplayer-encodewebm]').value = 'false'; }" <?php echo ($webmchecked." ".$ffmpeg_disabled_text); ?> />
1496
+ <label for="attachments[singleurl][kgflashmediaplayer-encodewebmcheck]">WEBM</label>
1497
+
1498
+ <input type="checkbox" id="attachments[singleurl][kgflashmediaplayer-encodeoggcheck]" name="attachments[singleurl][kgflashmediaplayer-encodeoggcheck]" value="checked" onclick="if(this.checked) { document.getElementById('attachments[singleurl][kgflashmediaplayer-encodeogg]').value = 'true'; } else { document.getElementById('attachments[singleurl][kgflashmediaplayer-encodeogg]').value = 'false'; }" <?php echo ($oggchecked." ".$ffmpeg_disabled_text); ?> />
1499
+ <label for="attachments[singleurl][kgflashmediaplayer-encodeoggcheck]">OGV</label>
1500
+
1501
+ <div style="display:inline;" id="attachments_singleurl_altembedselect"></div>
1502
+ <div style="display:block;" id="attachments_singleurl_encodeplaceholder"></div>
1503
+ <div style="display:block;" id="attachments_singleurl_encodeprogressplaceholder"></div>
1504
+
1505
+ <small><em>(Experimental) Generates video files compatible with most mobile & HTML5-compatible browsers.</em></small></td>
1506
+ </tr>
1507
+ <tr>
1508
+ <th valign="top" scope="row" class="label"><span class="alignleft"><label>Options</span></label></th>
1509
+ <td><input type="checkbox" name="downloadlink" id="downloadlink" value="true" class="field" /><label for="downloadlink">Generate Download Link Below Video <small>(Makes it easier for users to download video file)</small></label></td>
1510
+ </tr>
1511
+ <tr class="submit">
1512
+ <td></td>
1513
+ <td>
1514
+ <input type="button" onclick="kg_insert_shortcode();" name="insertonlybutton" id="insertonlybutton" class="button" value="Insert into Post" />
1515
+ </td>
1516
+ </tr>
1517
+ </tbody></table>
1518
+ </div>
1519
+ </div>
1520
+
1521
+ <?php
1522
+ $uploads = wp_upload_dir();
1523
+ $maxheight = get_option('wp_FMP_height');
1524
+ $maxwidth = get_option('wp_FMP_width');
1525
+ ?>
1526
+
1527
+ <input type='hidden' name='attachments[singleurl][kgflashmediaplayer-security]' id='attachments[singleurl][kgflashmediaplayer-security]' value='<?php echo wp_create_nonce('video-embed-thumbnail-generator-nonce'); ?>' />
1528
+ <input type='hidden' name='attachments[singleurl][kgflashmediaplayer-encodemobile]' id='attachments[singleurl][kgflashmediaplayer-encodemobile]' value='<?php echo get_option('wp_FMP_encodemobile'); ?>' />
1529
+ <input type='hidden' name='attachments[singleurl][kgflashmediaplayer-encodeogg]' id='attachments[singleurl][kgflashmediaplayer-encodeogg]' value='<?php echo get_option('wp_FMP_encodeogg'); ?>' />
1530
+ <input type='hidden' name='attachments[singleurl][kgflashmediaplayer-encodewebm]' id='attachments[singleurl][kgflashmediaplayer-encodewebm]' value='<?php echo get_option('wp_FMP_encodewebm'); ?>' />
1531
+ <input type='hidden' name='attachments[singleurl][kgflashmediaplayer-maxheight]' id='attachments[singleurl][kgflashmediaplayer-maxheight]' value='<?php echo($maxheight); ?>' />
1532
+ <input type='hidden' name='attachments[singleurl][kgflashmediaplayer-maxwidth]' id='attachments[singleurl][kgflashmediaplayer-maxwidth]' value='<?php echo($maxwidth); ?>' />
1533
+ <input type='hidden' name='attachments[singleurl][kgflashmediaplayer-aspect]' id='attachments[singleurl][kgflashmediaplayer-aspect]' value='<?php echo($maxheight/$maxwidth); ?>' />
1534
+ <input type='hidden' name='attachments[singleurl][kgflashmediaplayer-titlecode]' id='attachments[singleurl][kgflashmediaplayer-titlecode]' value='<?php echo get_option('wp_FMP_titlecode'); ?>' />
1535
+ </form>
1536
+
1537
+ <?php
1538
} //end media_embedurl_process
1539
1540
function kg_embedurl_handle() {
1734
}
1735
add_action('admin_print_styles', 'enqueue_kg_style');
1736
1737
add_action('admin_menu', 'addFMPOptionsPage');
1738
1739
?>