Version Description
- May 01, 2013 =
- Fixed bug that caused video control text to display below videos on iPhones.
- Changed method for saving video plays to the database. Now more secure and accurate.
Download this release
Release Info
Developer | kylegilman |
Plugin | Video Embed & Thumbnail Generator |
Version | 4.0.3 |
Comparing to | |
See all releases |
Code changes from version 4.0.2 to 4.0.3
- js/kgvid_video_embed.js +11 -12
- readme.txt +6 -1
- video-embed-thumbnail-generator.php +92 -48
js/kgvid_video_embed.js
CHANGED
@@ -22,7 +22,6 @@ function kgvid_setup_video(id, player_type, set_volume) {
|
|
22 |
}
|
23 |
|
24 |
function kgvid_ios_player(id) {
|
25 |
-
//var source = document.getElementById('video_'+id+'_html5_api').src;
|
26 |
var player = _V_('video_'+id);
|
27 |
var source = document.getElementById('video_'+id+'_html5_api').src
|
28 |
var poster = player.options.poster;
|
@@ -35,16 +34,20 @@ function kgvid_ios_player(id) {
|
|
35 |
if ( poster != null ) { ios_video += ' poster="'+poster+'" '; }
|
36 |
ios_video += '\><source src="'+source+'" type="video/mp4" /></video>';
|
37 |
}
|
38 |
-
else {
|
|
|
39 |
if ( poster != null ) { ios_video += '<img class="kgvid_ios_novideo" src="'+poster+'">'; }
|
40 |
-
ios_video += '</div>';
|
41 |
}
|
42 |
jQuery(player.el).remove();
|
|
|
43 |
jQuery('#video_'+id+'_div').prepend(ios_video);
|
44 |
if ( source != "" ) { document.getElementById('video_'+id).load(); }
|
45 |
}
|
46 |
|
47 |
function kgvid_resize_video(id, player_type, set_width, set_height) {
|
|
|
|
|
48 |
var aspect_ratio = Math.round(set_height/set_width*1000)/1000
|
49 |
var parent_width = jQuery('#kgvid_'+id+'_wrapper').parent().width();
|
50 |
if ( parent_width < set_width ) { set_width = parent_width; }
|
@@ -81,22 +84,19 @@ function kgvid_resize_video(id, player_type, set_width, set_height) {
|
|
81 |
jQuery('#video_'+id+'_caption').width(set_width-width_remove); //wraps long captions
|
82 |
}
|
83 |
|
84 |
-
function kgvid_video_counter(id,
|
85 |
var changed = false;
|
86 |
|
87 |
var played = jQuery('#video_'+id+'_div').data("played") || "not played";
|
88 |
if ( played == "not played" ) {
|
89 |
-
if (
|
90 |
-
plays++;
|
91 |
changed = true;
|
92 |
jQuery('#video_'+id+'_div').data("played", "played");
|
93 |
}
|
94 |
if (typeof _gaq != "undefined") { _gaq.push(["_trackEvent", "Videos", "Play Start", title]); }
|
95 |
}
|
96 |
if ( event == "end" ) {
|
97 |
-
if (
|
98 |
-
plays++;
|
99 |
-
ends++;
|
100 |
changed = true;
|
101 |
}
|
102 |
if (typeof _gaq != 'undefined') { _gaq.push(['_trackEvent', 'Videos', 'Complete View', title]); }
|
@@ -105,10 +105,9 @@ function kgvid_video_counter(id, plays, ends, event, title) {
|
|
105 |
jQuery.post(ajax_object.ajaxurl, {
|
106 |
action: 'kgvid_count_play',
|
107 |
post_id: id,
|
108 |
-
|
109 |
-
complete_views: ends
|
110 |
}, function(data) {
|
111 |
-
jQuery('#video_'+id+'_viewcount').html(
|
112 |
});
|
113 |
}
|
114 |
}
|
22 |
}
|
23 |
|
24 |
function kgvid_ios_player(id) {
|
|
|
25 |
var player = _V_('video_'+id);
|
26 |
var source = document.getElementById('video_'+id+'_html5_api').src
|
27 |
var poster = player.options.poster;
|
34 |
if ( poster != null ) { ios_video += ' poster="'+poster+'" '; }
|
35 |
ios_video += '\><source src="'+source+'" type="video/mp4" /></video>';
|
36 |
}
|
37 |
+
else {
|
38 |
+
var ios_video = '<div id="video_'+id+'" style="background-color:black;"><div class="kgvid_ios_novideo"></div>';
|
39 |
if ( poster != null ) { ios_video += '<img class="kgvid_ios_novideo" src="'+poster+'">'; }
|
40 |
+
ios_video += '</div>';
|
41 |
}
|
42 |
jQuery(player.el).remove();
|
43 |
+
console.log(ios_video);
|
44 |
jQuery('#video_'+id+'_div').prepend(ios_video);
|
45 |
if ( source != "" ) { document.getElementById('video_'+id).load(); }
|
46 |
}
|
47 |
|
48 |
function kgvid_resize_video(id, player_type, set_width, set_height) {
|
49 |
+
var iOS = ( navigator.userAgent.match(/(iPad|iPhone|iPod)/i) ? true : false );
|
50 |
+
if ( iOS ) { player_type = "iOS"; }
|
51 |
var aspect_ratio = Math.round(set_height/set_width*1000)/1000
|
52 |
var parent_width = jQuery('#kgvid_'+id+'_wrapper').parent().width();
|
53 |
if ( parent_width < set_width ) { set_width = parent_width; }
|
84 |
jQuery('#video_'+id+'_caption').width(set_width-width_remove); //wraps long captions
|
85 |
}
|
86 |
|
87 |
+
function kgvid_video_counter(id, event, countable, title) {
|
88 |
var changed = false;
|
89 |
|
90 |
var played = jQuery('#video_'+id+'_div').data("played") || "not played";
|
91 |
if ( played == "not played" ) {
|
92 |
+
if (countable) { //video is in the db
|
|
|
93 |
changed = true;
|
94 |
jQuery('#video_'+id+'_div').data("played", "played");
|
95 |
}
|
96 |
if (typeof _gaq != "undefined") { _gaq.push(["_trackEvent", "Videos", "Play Start", title]); }
|
97 |
}
|
98 |
if ( event == "end" ) {
|
99 |
+
if (countable) { //video is in the db
|
|
|
|
|
100 |
changed = true;
|
101 |
}
|
102 |
if (typeof _gaq != 'undefined') { _gaq.push(['_trackEvent', 'Videos', 'Complete View', title]); }
|
105 |
jQuery.post(ajax_object.ajaxurl, {
|
106 |
action: 'kgvid_count_play',
|
107 |
post_id: id,
|
108 |
+
video_event: event
|
|
|
109 |
}, function(data) {
|
110 |
+
jQuery('#video_'+id+'_viewcount').html(data+' views');
|
111 |
});
|
112 |
}
|
113 |
}
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=kyleg
|
|
4 |
Tags: video, video gallery, html5, shortcode, thumbnail, ffmpeg, libav, embed, mobile, webm, ogg, h.264
|
5 |
Requires at least: 3.2
|
6 |
Tested up to: 3.6
|
7 |
-
Stable tag: 4.0.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -136,6 +136,10 @@ Use the "Embed from URL" tab. Use the format http://username:password@yourdomain
|
|
136 |
|
137 |
== Changelog ==
|
138 |
|
|
|
|
|
|
|
|
|
139 |
= 4.0.2 - April 25, 2013 =
|
140 |
* Plugin settings are no longer re-saved to the database on every page load. Should speed things up a little.
|
141 |
* Changed CSS to discourage theme styles from overriding embed code overlay styles.
|
@@ -144,6 +148,7 @@ Use the "Embed from URL" tab. Use the format http://username:password@yourdomain
|
|
144 |
* Added options to display video title and embed code overlays on video player, and captions and view counts below videos.
|
145 |
* Added option to filter your theme's video attachment page template to display the video instead of WordPress's default behavior of just showing the title of the video. For backwards compatibility retained old method of completely replacing the video attachment template with a video player.
|
146 |
* Redesigned settings page to save using AJAX, and added a sample video player so changes are seen immediately.
|
|
|
147 |
* Added iframe method to embed your videos on other websites.
|
148 |
* Additional video formats encoded by the plugin are now added to the WordPress database as video attachments. To avoid a Russian nesting doll scenario these child attachments do not have the fields for creating thumbnails and encoding additional formats.
|
149 |
* Changed encoded H.264 extensions from .m4v to .mp4 to increase compatibility with WordPress 3.6's new video capabilities. Existing M4V files will still work.
|
4 |
Tags: video, video gallery, html5, shortcode, thumbnail, ffmpeg, libav, embed, mobile, webm, ogg, h.264
|
5 |
Requires at least: 3.2
|
6 |
Tested up to: 3.6
|
7 |
+
Stable tag: 4.0.3
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
136 |
|
137 |
== Changelog ==
|
138 |
|
139 |
+
= 4.0.3 - May 01, 2013 =
|
140 |
+
* Fixed bug that caused video control text to display below videos on iPhones.
|
141 |
+
* Changed method for saving video plays to the database. Now more secure and accurate.
|
142 |
+
|
143 |
= 4.0.2 - April 25, 2013 =
|
144 |
* Plugin settings are no longer re-saved to the database on every page load. Should speed things up a little.
|
145 |
* Changed CSS to discourage theme styles from overriding embed code overlay styles.
|
148 |
* Added options to display video title and embed code overlays on video player, and captions and view counts below videos.
|
149 |
* Added option to filter your theme's video attachment page template to display the video instead of WordPress's default behavior of just showing the title of the video. For backwards compatibility retained old method of completely replacing the video attachment template with a video player.
|
150 |
* Redesigned settings page to save using AJAX, and added a sample video player so changes are seen immediately.
|
151 |
+
* Added validation to settings page to require maximum width & height values for embedded videos.
|
152 |
* Added iframe method to embed your videos on other websites.
|
153 |
* Additional video formats encoded by the plugin are now added to the WordPress database as video attachments. To avoid a Russian nesting doll scenario these child attachments do not have the fields for creating thumbnails and encoding additional formats.
|
154 |
* Changed encoded H.264 extensions from .m4v to .mp4 to increase compatibility with WordPress 3.6's new video capabilities. Existing M4V files will still work.
|
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/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: 4.0.
|
7 |
Author: Kyle Gilman
|
8 |
Author URI: http://www.kylegilman.net/
|
9 |
|
@@ -42,7 +42,7 @@ if ( ! defined( 'ABSPATH' ) )
|
|
42 |
|
43 |
function kgvid_default_options_fn() {
|
44 |
$options = array(
|
45 |
-
"version"=>4.
|
46 |
"embed_method"=>"Video.js",
|
47 |
"template"=>false,
|
48 |
"template_gentle"=>"on",
|
@@ -85,7 +85,8 @@ function kgvid_default_options_fn() {
|
|
85 |
"stream_type"=>"liveOrRecorded",
|
86 |
"scale_mode"=>"letterbox",
|
87 |
"autohide"=>"on",
|
88 |
-
"playbutton"=>"on"
|
|
|
89 |
return $options;
|
90 |
}
|
91 |
|
@@ -545,7 +546,6 @@ function kgvid_video_embed_print_scripts() {
|
|
545 |
}
|
546 |
add_action('wp_head', 'kgvid_video_embed_print_scripts');
|
547 |
|
548 |
-
|
549 |
function KGVID_shortcode($atts, $content = ''){
|
550 |
|
551 |
$options = get_option('kgvid_video_embed_options');
|
@@ -624,7 +624,7 @@ function KGVID_shortcode($atts, $content = ''){
|
|
624 |
$div_suffix = $id;
|
625 |
$encodevideo_info = kgvid_encodevideo_info($content, $id);
|
626 |
$attachment_info = get_post( $id );
|
627 |
-
|
628 |
$poster_id = get_post_meta($id, '_kgflashmediaplayer-poster-id', true);
|
629 |
if ( !empty($poster_id) ) {
|
630 |
//$poster_post = get_post($poster_id);
|
@@ -635,8 +635,6 @@ function KGVID_shortcode($atts, $content = ''){
|
|
635 |
}
|
636 |
}
|
637 |
|
638 |
-
$plays = intval(get_post_meta($id, "_kgflashmediaplayer-starts", true));
|
639 |
-
$ends = intval(get_post_meta($id, "_kgflashmediaplayer-completeviews", true));
|
640 |
if ( $query_atts['title'] == "true" ) {
|
641 |
$query_atts['title'] = $attachment_info->post_title;
|
642 |
$stats_title = $query_atts['title'];
|
@@ -644,6 +642,8 @@ function KGVID_shortcode($atts, $content = ''){
|
|
644 |
else { $stats_title = $attachment_info->post_title; }
|
645 |
if ( empty($query_atts['caption']) ) { $query_atts['caption'] = $attachment_info->post_excerpt; }
|
646 |
if ( empty($query_atts['description']) ) { $query_atts['description'] = $attachment_info->post_content; }
|
|
|
|
|
647 |
}
|
648 |
else { //video is not in the database
|
649 |
$div_suffix = substr(uniqid(rand(), true),0,4);
|
@@ -655,8 +655,8 @@ function KGVID_shortcode($atts, $content = ''){
|
|
655 |
if ( $query_atts['embedcode'] == "true" ) {
|
656 |
$query_atts['embedcode'] = "false"; //can't use embed code with videos that are not in the database
|
657 |
}
|
658 |
-
|
659 |
-
$
|
660 |
}
|
661 |
|
662 |
if ( in_array($moviefiletype, $compatible) ) {
|
@@ -665,6 +665,16 @@ function KGVID_shortcode($atts, $content = ''){
|
|
665 |
}
|
666 |
else { $encodevideo_info["original_exists"] = false; }
|
667 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
668 |
if ( $options['embed_method'] == "Strobe Media Playback" ) {
|
669 |
|
670 |
$video_swf = plugins_url('', __FILE__)."/flash/StrobeMediaPlayback.swf";
|
@@ -698,7 +708,7 @@ function KGVID_shortcode($atts, $content = ''){
|
|
698 |
if($query_atts["backgroundcolor"] != '') { $flashvars .= ", backgroundColor:'".$query_atts["backgroundcolor"]."'"; }
|
699 |
if($query_atts["configuration"] != '') { $flashvars .= ", configuration:'".urlencode($query_atts["configuration"])."'"; }
|
700 |
if($query_atts["skin"] != '') { $flashvars .= ", skin:'".urlencode($query_atts["skin"])."'"; }
|
701 |
-
$flashvars .= ", verbose:'true', javascriptCallbackFunction:'function(id){ var player=document.getElementById(id); if ( player.getState() == \"buffering\" || player.getState() == \"playing\" ) { kgvid_video_counter(\"".$div_suffix."\", ".$
|
702 |
$flashvars .= "}";
|
703 |
|
704 |
$params = "{wmode:'opaque', allowfullscreen:'true', allowScriptAccess:'always', base:'".plugins_url("", __FILE__)."/flash/'}";
|
@@ -783,29 +793,28 @@ function KGVID_shortcode($atts, $content = ''){
|
|
783 |
if ( $query_atts['autoplay'] == "true" ) { $timeout = "0"; }
|
784 |
else { $timeout = "500"; }
|
785 |
|
786 |
-
$code .= "<script type='text/javascript'>
|
787 |
-
var player_type = '".$options['embed_method']."';";
|
788 |
if ( $options['embed_method'] == "Video.js" || ($options['embed_method'] == "Strobe Media Playback" && !$flash_source_found) ) {
|
789 |
$code .= "\n\t\t\t"."_V_('video_".$div_suffix."').ready(function(){
|
790 |
-
kgvid_setup_video('".$div_suffix."',
|
791 |
this.addEvent('play', function(){";
|
792 |
if ( $kgvid_meta ) {
|
793 |
$code .= "\n\t\t\t"."jQuery('#video_".$div_suffix."_div').hover(function(){ jQuery('#video_".$div_suffix."_meta').addClass('kgvid_video_meta_hover'); },function(){ jQuery('#video_".$div_suffix."_meta').removeClass('kgvid_video_meta_hover'); });
|
794 |
jQuery('#video_".$div_suffix."_meta').removeClass('kgvid_video_meta_hover');";
|
795 |
} //end if kgvid_meta
|
796 |
$code .= "\n\t\t\t"."setTimeout(function() { _V_('video_".$div_suffix."').controlBar.fadeOut(); }, ".$timeout.");
|
797 |
-
kgvid_video_counter('".$div_suffix."', '
|
798 |
});
|
799 |
this.addEvent('ended', function(){
|
800 |
-
kgvid_video_counter('".$div_suffix."', '
|
801 |
setTimeout(function() { jQuery('#video_".$div_suffix." > .vjs-loading-spinner').hide(); }, 250);
|
802 |
});
|
803 |
});";
|
804 |
}
|
805 |
if ( $options['embed_method'] == "Strobe Media Playback" && $flash_source_found ) {
|
806 |
$code .= "swfobject.embedSWF('".$video_swf."', 'video_".$div_suffix."', '".trim($query_atts['width'])."', '".trim($query_atts['height'])."', '".$minimum_flash."', '".plugins_url("", __FILE__)."/flash/expressInstall.swf', $flashvars, $params, '', function() {
|
807 |
-
kgvid_setup_video('".$div_suffix."',
|
808 |
-
kgvid_resize_video('".$div_suffix."',
|
809 |
});
|
810 |
jQuery('#kgvid_".$div_suffix."_wrapper').hover(
|
811 |
function() { jQuery('#video_".$div_suffix."_watermark').fadeOut(100); },
|
@@ -813,18 +822,19 @@ function KGVID_shortcode($atts, $content = ''){
|
|
813 |
);";
|
814 |
}
|
815 |
$code .= "\n\t\t\t"."var iOS = ( navigator.userAgent.match(/(iPad|iPhone|iPod)/i) ? true : false );
|
816 |
-
if (iOS) {
|
817 |
-
|
|
|
818 |
kgvid_ios_player('".$div_suffix."');
|
819 |
-
player_type = 'iOS';
|
820 |
document.getElementById('video_".$div_suffix."').addEventListener('play',function(){
|
821 |
jQuery('#video_".$div_suffix."_meta').removeClass('kgvid_video_meta_hover');
|
822 |
-
kgvid_video_counter('".$div_suffix."', '
|
823 |
});
|
824 |
}
|
825 |
-
kgvid_resize_video('".$div_suffix."',
|
826 |
-
window.addEventListener('resize', resize_".$div_suffix."=function(){ kgvid_resize_video('".$div_suffix."', '".$options['embed_method']."', '".$query_atts["width"]."', '".$query_atts["height"]."'); }, false);
|
827 |
-
|
|
|
828 |
|
829 |
} //if not gallery
|
830 |
|
@@ -1284,6 +1294,7 @@ function kgvid_video_embed_options_init() {
|
|
1284 |
add_settings_field('featured', 'Featured Image:', 'kgvid_featured_callback', __FILE__, 'kgvid_video_embed_plugin_settings', array( 'label_for' => 'featured' ) );
|
1285 |
add_settings_field('thumb_parent', 'Attach thumbnails to:', 'kgvid_thumb_parent_callback', __FILE__, 'kgvid_video_embed_plugin_settings', array( 'label_for' => 'thumb_parent' ) );
|
1286 |
add_settings_field('delete_children', 'Delete associated attachments:', 'kgvid_delete_children_callback', __FILE__, 'kgvid_video_embed_plugin_settings', array( 'label_for' => 'delete_children' ) );
|
|
|
1287 |
add_settings_field('titlecode', 'Video title text HTML formatting:', 'kgvid_titlecode_callback', __FILE__, 'kgvid_video_embed_plugin_settings', array( 'label_for' => 'titlecode' ) );
|
1288 |
add_settings_field('template', 'Attachment template display:', 'kgvid_template_callback', __FILE__, 'kgvid_video_embed_plugin_settings', array( 'label_for' => 'template' ) );
|
1289 |
}
|
@@ -1510,6 +1521,11 @@ add_action('admin_init', 'kgvid_video_embed_options_init' );
|
|
1510 |
echo "</select> <a class='kgvid_tooltip' href='javascript:void(0);'><img src='../wp-includes/images/blank.gif'><span class='kgvid_tooltip_classic'>If you delete the original video you can choose to delete all associated attachments (thumbnails & videos) or keep the thumbnail.</span></a>";
|
1511 |
}
|
1512 |
|
|
|
|
|
|
|
|
|
|
|
1513 |
function kgvid_titlecode_callback() {
|
1514 |
$options = get_option('kgvid_video_embed_options');
|
1515 |
echo "<input class='regular-text code' id='titlecode' name='kgvid_video_embed_options[titlecode]' type='text' value='".htmlentities(stripslashes($options['titlecode']))."' /> <a class='kgvid_tooltip' href='javascript:void(0);'><img src='../wp-includes/images/blank.gif'><span class='kgvid_tooltip_classic'>HTML tag applied to titles inserted above the video. Ex: <strong>, <em>, <H2>, <span class='videotitle'>. Corresponding closing tags will be applied to the end of the title automatically.</span></a>";
|
@@ -1687,14 +1703,37 @@ function kgvid_ajax_save_settings() {
|
|
1687 |
}
|
1688 |
add_action('wp_ajax_kgvid_save_settings', 'kgvid_ajax_save_settings');
|
1689 |
|
1690 |
-
/* function kgvid_add_attachment_handler($post_id) { // This will start thumbnail generating automatically in a future version
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1691 |
|
1692 |
$options = get_option('kgvid_video_embed_options');
|
|
|
|
|
1693 |
$movieurl = wp_get_attachment_url($post_id);
|
1694 |
-
|
1695 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1696 |
}
|
1697 |
-
add_action('
|
1698 |
|
1699 |
/**
|
1700 |
* Adding our custom fields to the $form_fields array
|
@@ -1707,8 +1746,6 @@ function kgvid_image_attachment_fields_to_edit($form_fields, $post) {
|
|
1707 |
|
1708 |
$options = get_option('kgvid_video_embed_options');
|
1709 |
|
1710 |
-
|
1711 |
-
|
1712 |
if ( substr($post->post_mime_type, 0, 5) == 'video' && (empty($post->post_parent) || (strpos(get_post_mime_type( $post->post_parent ), 'video') === false && get_post_meta($post->ID, '_kgflashmediaplayer-externalurl', true) == false)) ) { //if the attachment is a video with no parent or if it has a parent the parent is not a video and the video doesn't have the externalurl post meta
|
1713 |
|
1714 |
$field_id = kgvid_backwards_compatible($post->ID);
|
@@ -2287,7 +2324,7 @@ function kgvid_video_attachment_template() {
|
|
2287 |
if ( (!is_array($kgvid_video_embed) && $kgvid_video_embed == "true") ) { $kgvid_video_embed = array ( 'enable' => 'true' ); } //maintain backwards compatibility
|
2288 |
|
2289 |
|
2290 |
-
if ( $kgvid_video_embed['enable'] == 'true' && (strpos($post->post_mime_type,"video") !== false || array_key_exists('sample', $kgvid_video_embed)) ) {
|
2291 |
|
2292 |
remove_action('wp_head', '_admin_bar_bump_cb'); //don't show the WordPress admin bar if you're logged in
|
2293 |
|
@@ -2307,6 +2344,21 @@ function kgvid_video_attachment_template() {
|
|
2307 |
}
|
2308 |
add_action('template_redirect', 'kgvid_video_attachment_template');
|
2309 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2310 |
function kgvid_cleanup_generated_logfiles_handler($logfile) {
|
2311 |
$lastmodified = "";
|
2312 |
if ( file_exists($logfile) ) { $lastmodified = filemtime($logfile); }
|
@@ -2568,7 +2620,7 @@ function kgvid_enqueue_videos($postID, $movieurl, $encode_checked, $parent_id) {
|
|
2568 |
$arr = array ( "thumbnaildisplaycode"=>$thumbnaildisplaycode, "embed_display"=>$thumbnaildisplaycode, "lastthumbnumber"=>"break" );
|
2569 |
echo json_encode($arr);
|
2570 |
} //can't open movie
|
2571 |
-
}
|
2572 |
|
2573 |
function kgivd_save_singleurl_poster($parent_id, $poster, $movieurl) { //called by the "Embed Video from URL" tab when submitting
|
2574 |
|
@@ -3208,16 +3260,6 @@ function kgvid_ajax_delete_video() {
|
|
3208 |
$deleted = wp_delete_attachment($attachment_id);
|
3209 |
if ( !empty($deleted) ) { $deleted = true; }
|
3210 |
}
|
3211 |
-
$video_embed_queue = get_option('kgvid_video_embed_queue');
|
3212 |
-
/*if ( !empty($video_embed_queue) ) {
|
3213 |
-
foreach ($video_embed_queue as $video_key => $video_entry) {
|
3214 |
-
if ( $video_entry['movieurl'] == $movieurl ) {
|
3215 |
-
$video_embed_queue[$video_key]['encode_formats'][$format]['status'] = "deleted";
|
3216 |
-
update_option('kgvid_video_embed_queue', $video_embed_queue);
|
3217 |
-
break;
|
3218 |
-
}
|
3219 |
-
}
|
3220 |
-
}*/
|
3221 |
echo($deleted);
|
3222 |
die();
|
3223 |
|
@@ -3537,12 +3579,14 @@ add_action('wp_ajax_kgvid_rescan_external_server', 'kgvid_ajax_rescan_external_s
|
|
3537 |
|
3538 |
function kgvid_count_play() {
|
3539 |
$post_id = $_POST['post_id'];
|
3540 |
-
$
|
3541 |
-
$
|
3542 |
-
|
3543 |
-
|
3544 |
-
|
3545 |
-
|
|
|
|
|
3546 |
die(); // stop executing script
|
3547 |
}
|
3548 |
add_action( 'wp_ajax_kgvid_count_play', 'kgvid_count_play' ); // ajax for logged in users
|
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/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: 4.0.3
|
7 |
Author: Kyle Gilman
|
8 |
Author URI: http://www.kylegilman.net/
|
9 |
|
42 |
|
43 |
function kgvid_default_options_fn() {
|
44 |
$options = array(
|
45 |
+
"version"=>4.03,
|
46 |
"embed_method"=>"Video.js",
|
47 |
"template"=>false,
|
48 |
"template_gentle"=>"on",
|
85 |
"stream_type"=>"liveOrRecorded",
|
86 |
"scale_mode"=>"letterbox",
|
87 |
"autohide"=>"on",
|
88 |
+
"playbutton"=>"on"
|
89 |
+
);
|
90 |
return $options;
|
91 |
}
|
92 |
|
546 |
}
|
547 |
add_action('wp_head', 'kgvid_video_embed_print_scripts');
|
548 |
|
|
|
549 |
function KGVID_shortcode($atts, $content = ''){
|
550 |
|
551 |
$options = get_option('kgvid_video_embed_options');
|
624 |
$div_suffix = $id;
|
625 |
$encodevideo_info = kgvid_encodevideo_info($content, $id);
|
626 |
$attachment_info = get_post( $id );
|
627 |
+
|
628 |
$poster_id = get_post_meta($id, '_kgflashmediaplayer-poster-id', true);
|
629 |
if ( !empty($poster_id) ) {
|
630 |
//$poster_post = get_post($poster_id);
|
635 |
}
|
636 |
}
|
637 |
|
|
|
|
|
638 |
if ( $query_atts['title'] == "true" ) {
|
639 |
$query_atts['title'] = $attachment_info->post_title;
|
640 |
$stats_title = $query_atts['title'];
|
642 |
else { $stats_title = $attachment_info->post_title; }
|
643 |
if ( empty($query_atts['caption']) ) { $query_atts['caption'] = $attachment_info->post_excerpt; }
|
644 |
if ( empty($query_atts['description']) ) { $query_atts['description'] = $attachment_info->post_content; }
|
645 |
+
|
646 |
+
$countable = true;
|
647 |
}
|
648 |
else { //video is not in the database
|
649 |
$div_suffix = substr(uniqid(rand(), true),0,4);
|
655 |
if ( $query_atts['embedcode'] == "true" ) {
|
656 |
$query_atts['embedcode'] = "false"; //can't use embed code with videos that are not in the database
|
657 |
}
|
658 |
+
|
659 |
+
$countable = false;
|
660 |
}
|
661 |
|
662 |
if ( in_array($moviefiletype, $compatible) ) {
|
665 |
}
|
666 |
else { $encodevideo_info["original_exists"] = false; }
|
667 |
|
668 |
+
/* if ( $query_atts['video_security'] && !empty($id) ) {
|
669 |
+
|
670 |
+
$token = bin2hex(openssl_random_pseudo_bytes(32));
|
671 |
+
foreach ($video_formats as $name => $type) {
|
672 |
+
if ( $encodevideo_info[$name."_exists"] ) {
|
673 |
+
$encodevideo_info[$name.'url'] = site_url('/')."?kgvid_video_embed[id]=".$id."&kgvid_video_embed[format]=".$name."&kgvid_video_embed[token]=".$token;
|
674 |
+
}
|
675 |
+
}
|
676 |
+
}*/
|
677 |
+
|
678 |
if ( $options['embed_method'] == "Strobe Media Playback" ) {
|
679 |
|
680 |
$video_swf = plugins_url('', __FILE__)."/flash/StrobeMediaPlayback.swf";
|
708 |
if($query_atts["backgroundcolor"] != '') { $flashvars .= ", backgroundColor:'".$query_atts["backgroundcolor"]."'"; }
|
709 |
if($query_atts["configuration"] != '') { $flashvars .= ", configuration:'".urlencode($query_atts["configuration"])."'"; }
|
710 |
if($query_atts["skin"] != '') { $flashvars .= ", skin:'".urlencode($query_atts["skin"])."'"; }
|
711 |
+
$flashvars .= ", verbose:'true', javascriptCallbackFunction:'function(id){ var player=document.getElementById(id); if ( player.getState() == \"buffering\" || player.getState() == \"playing\" ) { kgvid_video_counter(\"".$div_suffix."\", '".$countable."', \"play\" '".esc_js($stats_title)."'); } }'"; //apparently this is necessary to turn on the js API
|
712 |
$flashvars .= "}";
|
713 |
|
714 |
$params = "{wmode:'opaque', allowfullscreen:'true', allowScriptAccess:'always', base:'".plugins_url("", __FILE__)."/flash/'}";
|
793 |
if ( $query_atts['autoplay'] == "true" ) { $timeout = "0"; }
|
794 |
else { $timeout = "500"; }
|
795 |
|
796 |
+
$code .= "<script type='text/javascript'>";
|
|
|
797 |
if ( $options['embed_method'] == "Video.js" || ($options['embed_method'] == "Strobe Media Playback" && !$flash_source_found) ) {
|
798 |
$code .= "\n\t\t\t"."_V_('video_".$div_suffix."').ready(function(){
|
799 |
+
kgvid_setup_video('".$div_suffix."', '".$options['embed_method']."', '".$query_atts["volume"]."');
|
800 |
this.addEvent('play', function(){";
|
801 |
if ( $kgvid_meta ) {
|
802 |
$code .= "\n\t\t\t"."jQuery('#video_".$div_suffix."_div').hover(function(){ jQuery('#video_".$div_suffix."_meta').addClass('kgvid_video_meta_hover'); },function(){ jQuery('#video_".$div_suffix."_meta').removeClass('kgvid_video_meta_hover'); });
|
803 |
jQuery('#video_".$div_suffix."_meta').removeClass('kgvid_video_meta_hover');";
|
804 |
} //end if kgvid_meta
|
805 |
$code .= "\n\t\t\t"."setTimeout(function() { _V_('video_".$div_suffix."').controlBar.fadeOut(); }, ".$timeout.");
|
806 |
+
kgvid_video_counter('".$div_suffix."', 'play', '".$countable."', '".esc_js($stats_title)."');
|
807 |
});
|
808 |
this.addEvent('ended', function(){
|
809 |
+
kgvid_video_counter('".$div_suffix."', 'end', '".$countable."', '".esc_js($stats_title)."');
|
810 |
setTimeout(function() { jQuery('#video_".$div_suffix." > .vjs-loading-spinner').hide(); }, 250);
|
811 |
});
|
812 |
});";
|
813 |
}
|
814 |
if ( $options['embed_method'] == "Strobe Media Playback" && $flash_source_found ) {
|
815 |
$code .= "swfobject.embedSWF('".$video_swf."', 'video_".$div_suffix."', '".trim($query_atts['width'])."', '".trim($query_atts['height'])."', '".$minimum_flash."', '".plugins_url("", __FILE__)."/flash/expressInstall.swf', $flashvars, $params, '', function() {
|
816 |
+
kgvid_setup_video('".$div_suffix."', '".$options['embed_method']."', '".$query_atts["volume"]."');
|
817 |
+
kgvid_resize_video('".$div_suffix."', '".$options['embed_method']."', '".$query_atts["width"]."', '".$query_atts["height"]."');
|
818 |
});
|
819 |
jQuery('#kgvid_".$div_suffix."_wrapper').hover(
|
820 |
function() { jQuery('#video_".$div_suffix."_watermark').fadeOut(100); },
|
822 |
);";
|
823 |
}
|
824 |
$code .= "\n\t\t\t"."var iOS = ( navigator.userAgent.match(/(iPad|iPhone|iPod)/i) ? true : false );
|
825 |
+
if (iOS) {
|
826 |
+
console.log('iOS');
|
827 |
+
if ( '".$options['embed_method']."' == 'Strobe Media Playback' ) { kgvid_setup_video('".$div_suffix."', 'Video.js', '".$query_atts["volume"]."'); }
|
828 |
kgvid_ios_player('".$div_suffix."');
|
|
|
829 |
document.getElementById('video_".$div_suffix."').addEventListener('play',function(){
|
830 |
jQuery('#video_".$div_suffix."_meta').removeClass('kgvid_video_meta_hover');
|
831 |
+
kgvid_video_counter('".$div_suffix."', 'play', '".$countable."', '".esc_js($stats_title)."');
|
832 |
});
|
833 |
}
|
834 |
+
kgvid_resize_video('".$div_suffix."', '".$options['embed_method']."', '".$query_atts["width"]."', '".$query_atts["height"]."');
|
835 |
+
window.addEventListener('resize', resize_".$div_suffix."=function(){ kgvid_resize_video('".$div_suffix."', '".$options['embed_method']."', '".$query_atts["width"]."', '".$query_atts["height"]."'); }, false);";
|
836 |
+
/* if ( $query_atts["video_security"] == "on" ) { $code .= "\n\t\t\t"."jQuery('#video_".$div_suffix."').bind('contextmenu',function() { return false; });"; } */
|
837 |
+
$code .= "\n\t\t"."</script>";
|
838 |
|
839 |
} //if not gallery
|
840 |
|
1294 |
add_settings_field('featured', 'Featured Image:', 'kgvid_featured_callback', __FILE__, 'kgvid_video_embed_plugin_settings', array( 'label_for' => 'featured' ) );
|
1295 |
add_settings_field('thumb_parent', 'Attach thumbnails to:', 'kgvid_thumb_parent_callback', __FILE__, 'kgvid_video_embed_plugin_settings', array( 'label_for' => 'thumb_parent' ) );
|
1296 |
add_settings_field('delete_children', 'Delete associated attachments:', 'kgvid_delete_children_callback', __FILE__, 'kgvid_video_embed_plugin_settings', array( 'label_for' => 'delete_children' ) );
|
1297 |
+
/* add_settings_field('video_security', 'Attempt to secure video file:', 'kgvid_video_security_callback', __FILE__, 'kgvid_video_embed_plugin_settings', array( 'label_for' => 'video_security' ) ); */
|
1298 |
add_settings_field('titlecode', 'Video title text HTML formatting:', 'kgvid_titlecode_callback', __FILE__, 'kgvid_video_embed_plugin_settings', array( 'label_for' => 'titlecode' ) );
|
1299 |
add_settings_field('template', 'Attachment template display:', 'kgvid_template_callback', __FILE__, 'kgvid_video_embed_plugin_settings', array( 'label_for' => 'template' ) );
|
1300 |
}
|
1521 |
echo "</select> <a class='kgvid_tooltip' href='javascript:void(0);'><img src='../wp-includes/images/blank.gif'><span class='kgvid_tooltip_classic'>If you delete the original video you can choose to delete all associated attachments (thumbnails & videos) or keep the thumbnail.</span></a>";
|
1522 |
}
|
1523 |
|
1524 |
+
/* function kgvid_video_security_callback() {
|
1525 |
+
$options = get_option('kgvid_video_embed_options');
|
1526 |
+
echo "<input ".checked( $options['video_security'], "on", false )." id='video_security' name='kgvid_video_embed_options[video_security]' type='checkbox' /> <label for='video_security'>Disable right-clicking on video and obscure the video's URL.</label> <a class='kgvid_tooltip' href='javascript:void(0);'><img src='../wp-includes/images/blank.gif'><span class='kgvid_tooltip_classic'>We can't prevent a user from simply saving the downloaded video file from the browser's cache, but this will make it a little more difficult to download your videos.</span></a>";
|
1527 |
+
} */
|
1528 |
+
|
1529 |
function kgvid_titlecode_callback() {
|
1530 |
$options = get_option('kgvid_video_embed_options');
|
1531 |
echo "<input class='regular-text code' id='titlecode' name='kgvid_video_embed_options[titlecode]' type='text' value='".htmlentities(stripslashes($options['titlecode']))."' /> <a class='kgvid_tooltip' href='javascript:void(0);'><img src='../wp-includes/images/blank.gif'><span class='kgvid_tooltip_classic'>HTML tag applied to titles inserted above the video. Ex: <strong>, <em>, <H2>, <span class='videotitle'>. Corresponding closing tags will be applied to the end of the title automatically.</span></a>";
|
1703 |
}
|
1704 |
add_action('wp_ajax_kgvid_save_settings', 'kgvid_ajax_save_settings');
|
1705 |
|
1706 |
+
/* function kgvid_add_attachment_handler($post_id) { // This will start encoding and thumbnail generating automatically in a future version
|
1707 |
+
|
1708 |
+
$post = get_post($post_id);
|
1709 |
+
if ( substr($post->post_mime_type, 0, 5) == 'video' && (empty($post->post_parent) || (strpos(get_post_mime_type( $post->post_parent ), 'video') === false && get_post_meta($post->ID, '_kgflashmediaplayer-externalurl', true) == false)) ) {
|
1710 |
+
$args = array($post_id);
|
1711 |
+
wp_schedule_single_event(time(), 'kgvid_cron_new_attachment', $args);
|
1712 |
+
spawn_cron();
|
1713 |
+
}
|
1714 |
+
|
1715 |
+
}
|
1716 |
+
add_action('add_attachment', 'kgvid_add_attachment_handler');
|
1717 |
+
|
1718 |
+
function kgvid_cron_new_attachment_handler($post_id) {
|
1719 |
|
1720 |
$options = get_option('kgvid_video_embed_options');
|
1721 |
+
$post = get_post($post_id);
|
1722 |
+
error_log($post_id);
|
1723 |
$movieurl = wp_get_attachment_url($post_id);
|
1724 |
+
$video_formats = kgvid_video_formats();
|
1725 |
+
$encode_checked = array();
|
1726 |
+
unset($video_formats['rotated']);
|
1727 |
+
$encode_checked['rotated'] = "false";
|
1728 |
+
foreach ( $video_formats as $name => $format_stats ) {
|
1729 |
+
if ( $options['encode_'.$name] == "on" ) { $encode_checked[$name] = "true"; }
|
1730 |
+
else { $encode_checked[$name] = "false"; }
|
1731 |
+
}
|
1732 |
+
//kgvid_make_thumbs($post_id, $movieurl, $options['generate_thumbs'], 1, 1, '', '', 'generate');
|
1733 |
+
$output = kgvid_enqueue_videos($post_id, $movieurl, $encode_checked, $post->post_parent);
|
1734 |
+
$output = kgvid_encode_videos();
|
1735 |
}
|
1736 |
+
add_action('kgvid_cron_new_attachment', 'kgvid_cron_new_attachment_handler'); */
|
1737 |
|
1738 |
/**
|
1739 |
* Adding our custom fields to the $form_fields array
|
1746 |
|
1747 |
$options = get_option('kgvid_video_embed_options');
|
1748 |
|
|
|
|
|
1749 |
if ( substr($post->post_mime_type, 0, 5) == 'video' && (empty($post->post_parent) || (strpos(get_post_mime_type( $post->post_parent ), 'video') === false && get_post_meta($post->ID, '_kgflashmediaplayer-externalurl', true) == false)) ) { //if the attachment is a video with no parent or if it has a parent the parent is not a video and the video doesn't have the externalurl post meta
|
1750 |
|
1751 |
$field_id = kgvid_backwards_compatible($post->ID);
|
2324 |
if ( (!is_array($kgvid_video_embed) && $kgvid_video_embed == "true") ) { $kgvid_video_embed = array ( 'enable' => 'true' ); } //maintain backwards compatibility
|
2325 |
|
2326 |
|
2327 |
+
if ( array_key_exists('enable', $kgvid_video_embed) && $kgvid_video_embed['enable'] == 'true' && (strpos($post->post_mime_type,"video") !== false || array_key_exists('sample', $kgvid_video_embed)) ) {
|
2328 |
|
2329 |
remove_action('wp_head', '_admin_bar_bump_cb'); //don't show the WordPress admin bar if you're logged in
|
2330 |
|
2344 |
}
|
2345 |
add_action('template_redirect', 'kgvid_video_attachment_template');
|
2346 |
|
2347 |
+
/* function kgvid_serve_secure_video_files($wp) {
|
2348 |
+
if ( array_key_exists('kgvid_video_embed', $wp->query_vars) && array_key_exists('id', $wp->query_vars['kgvid_video_embed']) && array_key_exists('format', $wp->query_vars['kgvid_video_embed']) && array_key_exists('token', $wp->query_vars['kgvid_video_embed']) ) {
|
2349 |
+
$kgvid_video_embed = $wp->query_vars['kgvid_video_embed'];
|
2350 |
+
if ( $kgvid_video_embed['format'] == "original" ) { $video_id = $kgvid_video_embed['id']; }
|
2351 |
+
else { $video_id = get_post_meta($kgvid_video_embed['id'], '_kgflashmediaplayer-format', $kgvid_video_embed['format'] ); }
|
2352 |
+
$url = wp_get_attachment_url($video_id);
|
2353 |
+
$type = get_post_mime_type($video_id);
|
2354 |
+
error_log($url);
|
2355 |
+
header('Location: ' .$url);
|
2356 |
+
header('Content-type: '.$type);
|
2357 |
+
exit(0);
|
2358 |
+
}
|
2359 |
+
}
|
2360 |
+
add_action('parse_request', 'kgvid_serve_secure_video_files'); */
|
2361 |
+
|
2362 |
function kgvid_cleanup_generated_logfiles_handler($logfile) {
|
2363 |
$lastmodified = "";
|
2364 |
if ( file_exists($logfile) ) { $lastmodified = filemtime($logfile); }
|
2620 |
$arr = array ( "thumbnaildisplaycode"=>$thumbnaildisplaycode, "embed_display"=>$thumbnaildisplaycode, "lastthumbnumber"=>"break" );
|
2621 |
echo json_encode($arr);
|
2622 |
} //can't open movie
|
2623 |
+
}
|
2624 |
|
2625 |
function kgivd_save_singleurl_poster($parent_id, $poster, $movieurl) { //called by the "Embed Video from URL" tab when submitting
|
2626 |
|
3260 |
$deleted = wp_delete_attachment($attachment_id);
|
3261 |
if ( !empty($deleted) ) { $deleted = true; }
|
3262 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3263 |
echo($deleted);
|
3264 |
die();
|
3265 |
|
3579 |
|
3580 |
function kgvid_count_play() {
|
3581 |
$post_id = $_POST['post_id'];
|
3582 |
+
$event = $_POST['video_event'];
|
3583 |
+
if ( $event == "play" ) { $event = "starts"; }
|
3584 |
+
if ( $event == "end" ) { $event = "completeviews"; }
|
3585 |
+
$plays = get_post_meta($post_id, '_kgflashmediaplayer-'.$event, true);
|
3586 |
+
if ( !empty($plays) ) { $plays = intval($plays)+1; }
|
3587 |
+
else { $plays = 1; }
|
3588 |
+
update_post_meta($post_id, '_kgflashmediaplayer-'.$event, $plays);
|
3589 |
+
echo $plays;
|
3590 |
die(); // stop executing script
|
3591 |
}
|
3592 |
add_action( 'wp_ajax_kgvid_count_play', 'kgvid_count_play' ); // ajax for logged in users
|