Video Embed & Thumbnail Generator - Version 4.6.5

Version Description

The plugin is still completely free until version 5.0. Video.js users will notice an updated player design if updating from 4.5.5.

Download this release

Release Info

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

Code changes from version 4.6.4 to 4.6.5

css/kgvid_styles.css CHANGED
@@ -119,7 +119,7 @@ img.kgvid_ios_novideo {
119
  .kgvid_title {
120
  font-size: 10pt;
121
  padding-left: 4px;
122
- margin: -6pt 6pt 6pt 2pt;
123
  }
124
 
125
  .kgvid_meta_icons {
119
  .kgvid_title {
120
  font-size: 10pt;
121
  padding-left: 4px;
122
+ line-height: 20pt;
123
  }
124
 
125
  .kgvid_meta_icons {
js/kgvid_video_embed.js CHANGED
@@ -7,7 +7,7 @@ jQuery('.kgvid_videodiv').each(function(){ //setup individual videos. WordPress
7
  if ( video_vars.player_type == "Video.js" ) {
8
 
9
  var videojs_options = { "html5": { "nativeTextTracks" : false }, "language": video_vars.locale };
10
- if ( video_vars.resize == "true" ) {
11
  videojs_options.fluid = true;
12
  }
13
  if ( video_vars.width != undefined && video_vars.width.indexOf('%') === -1 && video_vars.height != undefined ) {
@@ -650,7 +650,6 @@ function kgvid_resize_video(id) {
650
  }
651
 
652
  if ( video_vars.player_type == "WordPressDefault" ) {
653
- jQuery('#kgvid_'+id+'_wrapper').find('.wp-video').attr('style', 'width:'+set_width+'px; height:'+set_height+'px;');
654
  if ( typeof mejs !== 'undefined' ) { player = eval('mejs.players.'+jQuery('#kgvid_'+id+'_wrapper div.wp-video-shortcode').attr('id')); }
655
  }
656
 
@@ -791,18 +790,26 @@ function kgvid_video_counter(id, event) {
791
 
792
  if ( !isNaN(event) ) {
793
 
 
 
 
 
794
  if (typeof ga != "undefined") { ga("send", "event", "Videos", event+"%", title); }
795
  else if (typeof _gaq != "undefined") { _gaq.push(["_trackEvent", "Videos", event+"%", title]); }
796
 
797
  }
798
 
799
  if ( event == "end" ) {
 
800
  if (video_vars.countable) { //video is in the db
801
  changed = true;
802
  }
 
803
  if (typeof ga != "undefined") { ga("send", "event", "Videos", kgvidL10n_frontend.completeview, title); }
804
  else if (typeof _gaq != 'undefined') { _gaq.push(['_trackEvent', 'Videos', kgvidL10n_frontend.completeview, title]); }
 
805
  }
 
806
  if ( changed == true ) {
807
  jQuery.post(kgvidL10n_frontend.ajaxurl, {
808
  action: 'kgvid_count_play',
7
  if ( video_vars.player_type == "Video.js" ) {
8
 
9
  var videojs_options = { "html5": { "nativeTextTracks" : false }, "language": video_vars.locale };
10
+ if ( video_vars.resize == "true" || video_vars.fullwidth == "true" ) {
11
  videojs_options.fluid = true;
12
  }
13
  if ( video_vars.width != undefined && video_vars.width.indexOf('%') === -1 && video_vars.height != undefined ) {
650
  }
651
 
652
  if ( video_vars.player_type == "WordPressDefault" ) {
 
653
  if ( typeof mejs !== 'undefined' ) { player = eval('mejs.players.'+jQuery('#kgvid_'+id+'_wrapper div.wp-video-shortcode').attr('id')); }
654
  }
655
 
790
 
791
  if ( !isNaN(event) ) {
792
 
793
+ if (video_vars.countable) { //video is in the db
794
+ changed = true;
795
+ }
796
+
797
  if (typeof ga != "undefined") { ga("send", "event", "Videos", event+"%", title); }
798
  else if (typeof _gaq != "undefined") { _gaq.push(["_trackEvent", "Videos", event+"%", title]); }
799
 
800
  }
801
 
802
  if ( event == "end" ) {
803
+
804
  if (video_vars.countable) { //video is in the db
805
  changed = true;
806
  }
807
+
808
  if (typeof ga != "undefined") { ga("send", "event", "Videos", kgvidL10n_frontend.completeview, title); }
809
  else if (typeof _gaq != 'undefined') { _gaq.push(['_trackEvent', 'Videos', kgvidL10n_frontend.completeview, title]); }
810
+
811
  }
812
+
813
  if ( changed == true ) {
814
  jQuery.post(kgvidL10n_frontend.ajaxurl, {
815
  action: 'kgvid_count_play',
js/kgvid_video_plugin_admin.js CHANGED
@@ -224,6 +224,11 @@ function kgvid_draw_thumb_canvas(canvas, canvas_source) {
224
 
225
  }
226
 
 
 
 
 
 
227
  function kgvid_reveal_thumb_video(postID) {
228
  jQuery('#show-thumb-video-'+postID+' :first').toggleClass( 'kgvid-down-arrow kgvid-right-arrow' );
229
  var text = jQuery('#show-thumb-video-'+postID+' :nth-child(2)');
224
 
225
  }
226
 
227
+ function kgvid_reveal_video_stats(postID) {
228
+ jQuery('#show-video-stats-'+postID).hide();
229
+ jQuery('#video-'+postID+'-stats').animate({opacity: 'toggle', height: 'toggle'}, 500);
230
+ }
231
+
232
  function kgvid_reveal_thumb_video(postID) {
233
  jQuery('#show-thumb-video-'+postID+' :first').toggleClass( 'kgvid-down-arrow kgvid-right-arrow' );
234
  var text = jQuery('#show-thumb-video-'+postID+' :nth-child(2)');
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=kyleg
4
  Tags: video, video player, video gallery, html5, shortcode, thumbnail, video thumbnail, preview, poster, ffmpeg, libav, embed, oembed, mobile, webm, ogg, h.264, h264, vp9, responsive, mp4, jwplayer, resolution, analytics
5
  Requires at least: 4.4
6
  Tested up to: 4.5
7
- Stable tag: 4.6.4
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -236,6 +236,15 @@ Enter the username & password in the plugin settings "FFMPEG Settings" tab, or u
236
 
237
  == Changelog ==
238
 
 
 
 
 
 
 
 
 
 
239
  = 4.6.4 - May 5, 2016 =
240
  * Fixed bug that caused an error when feed pages were generated, possibly interrupting autosaves.
241
 
@@ -478,14 +487,8 @@ Enter the username & password in the plugin settings "FFMPEG Settings" tab, or u
478
 
479
  == Upgrade Notice ==
480
 
481
- = 4.6.3 =
482
- The plugin is still completely free until version 5.0. Video.js users will notice an updated player design if updating from 4.5.5.
483
-
484
- = 4.6.2 =
485
  The plugin is still completely free until version 5.0. Video.js users will notice an updated player design if updating from 4.5.5.
486
 
487
- = 4.6.1 =
488
- The plugin is still completely free until version 5.0. Video.js users will notice an updated player design.
489
-
490
  = 4.6 =
491
  The plugin is still completely free until version 5.0. Video.js users will notice an updated player design.
4
  Tags: video, video player, video gallery, html5, shortcode, thumbnail, video thumbnail, preview, poster, ffmpeg, libav, embed, oembed, mobile, webm, ogg, h.264, h264, vp9, responsive, mp4, jwplayer, resolution, analytics
5
  Requires at least: 4.4
6
  Tested up to: 4.5
7
+ Stable tag: 4.6.5
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
236
 
237
  == Changelog ==
238
 
239
+ = 4.6.5 - May 13, 2016 =
240
+ * Removed anonymous function to allow the plugin to run on PHP versions lower than 5.3.
241
+ * Added 25%, 50%, and 75% video view tracking to the WordPress admin area.
242
+ * Fixed width="100%" vertical video aspect ratio bug and now allowing other players to work with this still-not-recommended method.
243
+ * Modified resizing method for WordPress default player container.
244
+ * Fixed temporary thumbnail display when switching resolutions in a Video.js player that is set to a different aspect ratio from the video file.
245
+ * Disabled background page rendering request on autosaves and revisions.
246
+ * Adjusted title bar CSS again and increased WordPress Default play button z-index.
247
+
248
  = 4.6.4 - May 5, 2016 =
249
  * Fixed bug that caused an error when feed pages were generated, possibly interrupting autosaves.
250
 
487
 
488
  == Upgrade Notice ==
489
 
490
+ = 4.6.5 =
 
 
 
491
  The plugin is still completely free until version 5.0. Video.js users will notice an updated player design if updating from 4.5.5.
492
 
 
 
 
493
  = 4.6 =
494
  The plugin is still completely free until version 5.0. Video.js users will notice an updated player design.
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 or LIBAV for encoding.
6
- Version: 4.6.4
7
  Author: Kyle Gilman
8
  Author URI: http://www.kylegilman.net/
9
  Text Domain: video-embed-thumbnail-generator
@@ -59,7 +59,7 @@ function kgvid_default_options_fn() {
59
  $edit_others_capable = kgvid_check_if_capable('edit_others_posts');
60
 
61
  $options = array(
62
- "version" => '4.6.4',
63
  "embed_method" => "Video.js",
64
  "jw_player_id" => "",
65
  "template" => false,
@@ -256,6 +256,9 @@ function kgvid_get_attachment_meta($post_id) {
256
  'downloadlink' => $options['downloadlink'],
257
  'track' => '',
258
  'starts' => '0',
 
 
 
259
  'completeviews' => '0',
260
  'pickedformat' => '',
261
  'encodefullres' => '',
@@ -812,6 +815,10 @@ function kgvid_rrmdir($dir) {
812
  }
813
  }
814
 
 
 
 
 
815
  function kvid_readfile_chunked($file, $retbytes=TRUE) { //sends large files in chunks so PHP doesn't timeout
816
 
817
  $chunksize = 1 * (1024 * 1024);
@@ -1636,9 +1643,7 @@ function kgvid_get_first_embedded_video( $post ) {
1636
  if ( !empty($first_embedded_video_meta) ) {
1637
 
1638
  if ( is_array($first_embedded_video_meta['atts']) ) {
1639
- $dataattributes = array_map(function($value, $key) {
1640
- return $key.'="'.$value.'"';
1641
- }, array_values($first_embedded_video_meta['atts']), array_keys($first_embedded_video_meta['atts']));
1642
 
1643
  $dataattributes = ' '.implode(' ', $dataattributes);
1644
  }
@@ -2303,6 +2308,12 @@ function kgvid_single_video_code($query_atts, $atts, $content, $post_id) {
2303
  }
2304
  else { $kgvid_meta = false; }
2305
 
 
 
 
 
 
 
2306
  $video_variables = array(
2307
  'id' => $div_suffix,
2308
  'attachment_id' => $id,
@@ -5484,7 +5495,12 @@ function kgvid_image_attachment_fields_to_edit($form_fields, $post) {
5484
  if ( $post->post_mime_type != 'image/gif' ) {
5485
  $form_fields["views"]["label"] = __('Video Stats', 'video-embed-thumbnail-generator');
5486
  $form_fields["views"]["input"] = "html";
5487
- $form_fields["views"]["html"] = sprintf( _n('%d Start', '%d Starts', intval($kgvid_postmeta['starts']), 'video-embed-thumbnail-generator'), intval($kgvid_postmeta['starts']) ).', '.sprintf( _n('%d Complete View', '%d Complete Views', intval($kgvid_postmeta['completeviews']), 'video-embed-thumbnail-generator'), intval($kgvid_postmeta['completeviews']) ).'<br />'.__('Video ID:', 'video-embed-thumbnail-generator').' '.$post->ID;
 
 
 
 
 
5488
 
5489
  // ** Thumbnail section **//
5490
 
@@ -5733,9 +5749,12 @@ function kgvid_video_stats_column_data( $column_name, $id ) {
5733
  $kgvid_postmeta = kgvid_get_attachment_meta($id);
5734
  if ( is_array($kgvid_postmeta) && array_key_exists('starts', $kgvid_postmeta) && intval($kgvid_postmeta['starts']) > 0 ) {
5735
  /* translators: Start refers to the number of times a video has been started */
5736
- printf( _n('%d Start', '%d Starts', intval($kgvid_postmeta['starts']), 'video-embed-thumbnail-generator'), intval($kgvid_postmeta['starts']) );
5737
- echo '<br>';
5738
- printf( _n('%d Complete View', '%d Complete Views', intval($kgvid_postmeta['completeviews']), 'video-embed-thumbnail-generator'), intval($kgvid_postmeta['completeviews']) );
 
 
 
5739
  }
5740
  }
5741
 
@@ -8200,6 +8219,7 @@ function kgvid_count_play() {
8200
  $event = $_POST['video_event'];
8201
  if ( $event == "play" ) { $event = "starts"; }
8202
  if ( $event == "end" ) { $event = "completeviews"; }
 
8203
  $kgvid_postmeta = kgvid_get_attachment_meta($post_id);
8204
  $plays = $kgvid_postmeta[$event];
8205
  if ( !empty($plays) ) { $plays = intval($plays)+1; }
@@ -8294,9 +8314,12 @@ function kgvid_save_post($post_id) {
8294
 
8295
  $options = kgvid_get_options();
8296
 
8297
- if ( $options['open_graph'] == "on" ) {
 
 
8298
  //render the post when it's saved in case there's a do_shortcode call in it so open graph metadata makes it into wp_head()
8299
  $response = wp_remote_get( get_permalink($post_id), array('blocking' => false) );
 
8300
  }
8301
 
8302
  }
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 or LIBAV for encoding.
6
+ Version: 4.6.5
7
  Author: Kyle Gilman
8
  Author URI: http://www.kylegilman.net/
9
  Text Domain: video-embed-thumbnail-generator
59
  $edit_others_capable = kgvid_check_if_capable('edit_others_posts');
60
 
61
  $options = array(
62
+ "version" => '4.6.5',
63
  "embed_method" => "Video.js",
64
  "jw_player_id" => "",
65
  "template" => false,
256
  'downloadlink' => $options['downloadlink'],
257
  'track' => '',
258
  'starts' => '0',
259
+ 'play_25' => '0',
260
+ 'play_50' => '0',
261
+ 'play_75' => '0',
262
  'completeviews' => '0',
263
  'pickedformat' => '',
264
  'encodefullres' => '',
815
  }
816
  }
817
 
818
+ function kgvid_build_paired_attributes($value, $key) {
819
+ return $key.'="'.$value.'"';
820
+ }
821
+
822
  function kvid_readfile_chunked($file, $retbytes=TRUE) { //sends large files in chunks so PHP doesn't timeout
823
 
824
  $chunksize = 1 * (1024 * 1024);
1643
  if ( !empty($first_embedded_video_meta) ) {
1644
 
1645
  if ( is_array($first_embedded_video_meta['atts']) ) {
1646
+ $dataattributes = array_map('kgvid_build_paired_attributes', array_values($first_embedded_video_meta['atts']), array_keys($first_embedded_video_meta['atts']));
 
 
1647
 
1648
  $dataattributes = ' '.implode(' ', $dataattributes);
1649
  }
2308
  }
2309
  else { $kgvid_meta = false; }
2310
 
2311
+ if ( $query_atts['width'] == "100%" ) {
2312
+ $query_atts['width'] = $options['width'];
2313
+ $query_atts['height'] = $options['height'];
2314
+ $query_atts['fullwidth'] = "true";
2315
+ }
2316
+
2317
  $video_variables = array(
2318
  'id' => $div_suffix,
2319
  'attachment_id' => $id,
5495
  if ( $post->post_mime_type != 'image/gif' ) {
5496
  $form_fields["views"]["label"] = __('Video Stats', 'video-embed-thumbnail-generator');
5497
  $form_fields["views"]["input"] = "html";
5498
+ $form_fields["views"]["html"] = sprintf( _n('%1$s%2$d%3$s Play', '%1$s%2$d%3$s Plays', intval($kgvid_postmeta['starts']), 'video-embed-thumbnail-generator'), '<strong>', intval($kgvid_postmeta['starts']), '</strong>' ).'<span class="kgvid-reveal-thumb-video" onclick="kgvid_reveal_video_stats('.$post->ID.')" id="show-video-stats-'.$post->ID.'"><br /><a class="kgvid-show-video">'.__('(More...)', 'video-embed-thumbnail-generator').'</a></span><div style="display:none;" id="video-'.$post->ID.'-stats">'.
5499
+ intval($kgvid_postmeta['play_25']).' '.__('25%', 'video-embed-thumbnail-generator').
5500
+ '<br /><strong>'.intval($kgvid_postmeta['play_50']).'</strong> '.__('50%', 'video-embed-thumbnail-generator').
5501
+ '<br /><strong>'.intval($kgvid_postmeta['play_75']).'</strong> '.__('75%', 'video-embed-thumbnail-generator').
5502
+ '<br />'.sprintf( _n('%1$s%2$d%3$s Complete View', '%1$s%2$d%3$s Complete Views', intval($kgvid_postmeta['completeviews']), 'video-embed-thumbnail-generator'), '<strong>', intval($kgvid_postmeta['completeviews']), '</strong>' ).
5503
+ '<p>'.__('Video ID:', 'video-embed-thumbnail-generator').' '.$post->ID.'</p></div>';
5504
 
5505
  // ** Thumbnail section **//
5506
 
5749
  $kgvid_postmeta = kgvid_get_attachment_meta($id);
5750
  if ( is_array($kgvid_postmeta) && array_key_exists('starts', $kgvid_postmeta) && intval($kgvid_postmeta['starts']) > 0 ) {
5751
  /* translators: Start refers to the number of times a video has been started */
5752
+ printf( _n('%1$s%2$d%3$s Play', '%1$s%2$d%3$s Plays', intval($kgvid_postmeta['starts']), 'video-embed-thumbnail-generator'), '<strong>', intval($kgvid_postmeta['starts']), '</strong>' );
5753
+ echo '<br><strong>'.intval($kgvid_postmeta['play_25']).'</strong> 25%'.
5754
+ '<br><strong>'.intval($kgvid_postmeta['play_50']).'</strong> 50%'.
5755
+ '<br><strong>'.intval($kgvid_postmeta['play_75']).'</strong> 75%<br>';
5756
+ printf( _n('%1$s%2$d%3$s Complete View', '%1$s%2$d%3$s Complete Views', intval($kgvid_postmeta['completeviews']), 'video-embed-thumbnail-generator'), '<strong>', intval($kgvid_postmeta['completeviews']), '</strong>' );
5757
+
5758
  }
5759
  }
5760
 
8219
  $event = $_POST['video_event'];
8220
  if ( $event == "play" ) { $event = "starts"; }
8221
  if ( $event == "end" ) { $event = "completeviews"; }
8222
+ if ( is_numeric($event) ) { $event = "play_".$event; }
8223
  $kgvid_postmeta = kgvid_get_attachment_meta($post_id);
8224
  $plays = $kgvid_postmeta[$event];
8225
  if ( !empty($plays) ) { $plays = intval($plays)+1; }
8314
 
8315
  $options = kgvid_get_options();
8316
 
8317
+ if ( !wp_is_post_revision( $post_id ) && !wp_is_post_autosave( $post_id )
8318
+ && ( $options['open_graph'] == "on" || $options['twitter_card'] == "on" )
8319
+ ) {
8320
  //render the post when it's saved in case there's a do_shortcode call in it so open graph metadata makes it into wp_head()
8321
  $response = wp_remote_get( get_permalink($post_id), array('blocking' => false) );
8322
+
8323
  }
8324
 
8325
  }
video-js/video-quality-selector.js CHANGED
@@ -333,14 +333,16 @@ videojs.plugin( 'resolutionSelector', function( options ) {
333
  if ( current_time != 0 ) {
334
 
335
  player.pause();
336
-
 
 
337
  var canvas = document.createElement("canvas");
338
  canvas.className = 'kgvid_temp_thumb';
339
  canvas.width = player.width();
340
  canvas.height = player.height();
341
  var context = canvas.getContext('2d');
342
  context.fillRect(0, 0, player.width(), player.height());
343
- context.drawImage(video_el, 0, 0, player.width(), player.height());
344
  jQuery(video_el).parent().append(canvas);
345
 
346
  player.bigPlayButton.hide();
333
  if ( current_time != 0 ) {
334
 
335
  player.pause();
336
+ var real_aspect_ratio = Math.round(video_el.videoHeight/video_el.videoWidth*1000)/1000;
337
+ var thumbnail_width = player.height() / real_aspect_ratio;
338
+ var x_axis = (player.width() - thumbnail_width) / 2;
339
  var canvas = document.createElement("canvas");
340
  canvas.className = 'kgvid_temp_thumb';
341
  canvas.width = player.width();
342
  canvas.height = player.height();
343
  var context = canvas.getContext('2d');
344
  context.fillRect(0, 0, player.width(), player.height());
345
+ context.drawImage(video_el, x_axis, 0, thumbnail_width, player.height());
346
  jQuery(video_el).parent().append(canvas);
347
 
348
  player.bigPlayButton.hide();