Video Embed & Thumbnail Generator - Version 4.5.5

Version Description

  • August 20, 2015 =
  • Fixed a number of potential infinite loops and other recursion issues related to longstanding WordPress bug #17817.
  • Changed video player names with spaces (WordPress Default, JW Player) to one word camel case for JavaScript functions (WordPressDefault, JWPlayer).
Download this release

Release Info

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

Code changes from version 4.5.4 to 4.5.5

js/kgvid_video_embed.js CHANGED
@@ -135,7 +135,7 @@ function kgvid_SetVideo(id) { //for galleries
135
if ( meta > 0 ) {
136
jQuery('#kgvid-simplemodal-container').css('color','white'); //show text if there's anything to see below the video
137
meta_bump = 5;
138
- if ( video_vars.player_type == "JW Player" ) { meta_bump = 15; }
139
jQuery('#kgvid-simplemodal-container').height(jQuery('#kgvid-simplemodal-container').height() + meta_bump);
140
}
141
@@ -144,7 +144,7 @@ function kgvid_SetVideo(id) { //for galleries
144
videojs('video_'+id).play();
145
}//end if Video.js
146
147
- if ( video_vars.player_type == "WordPress Default" ) {
148
jQuery('#kgvid_'+id+'_wrapper video').mediaelementplayer({
149
success: function(mediaElement, domObject) {
150
if (mediaElement.pluginType == 'flash' || mediaElement.pluginType == 'silverlight') {
@@ -178,7 +178,7 @@ function kgvid_SetVideo(id) { //for galleries
178
videojs('video_'+id).pause();
179
setTimeout(function() { videojs('video_'+id).dispose(); }, 0);
180
}
181
- if ( video_vars.player_type == "JW Player" ) {
182
jwplayer(jQuery('#kgvid_'+id+'_wrapper .jwplayer').attr('id')).stop();
183
}
184
}
@@ -339,7 +339,7 @@ function kgvid_setup_video(id) {
339
340
} //end if Video.js
341
342
- if ( video_vars.player_type == "Strobe Media Playback" || video_vars.player_type == "WordPress Default" ) {
343
344
jQuery('#video_'+id+'_div').hover(
345
function(){
@@ -351,7 +351,7 @@ function kgvid_setup_video(id) {
351
);
352
} //end if Strobe Media Playback
353
354
- if ( video_vars.player_type == "WordPress Default" ) {
355
356
player = jQuery('#video_'+id+'_div video');
357
@@ -392,7 +392,7 @@ function kgvid_setup_video(id) {
392
393
} //end if WordPress Default
394
395
- if ( video_vars.player_type == "JW Player" ) {
396
player_id = jQuery('#video_'+id+'_div').children('div[id^="jwplayer"]').attr('id');
397
var player = jwplayer(player_id);
398
@@ -530,7 +530,7 @@ function kgvid_resize_video(id) {
530
jQuery('#video_'+id).attr('width',set_width).attr('height',set_height);
531
jQuery('#video_'+id+'_html5_api').attr('width',set_width).attr('height',set_height);
532
}
533
- if ( video_vars.player_type == "WordPress Default" ) {
534
jQuery('#kgvid_'+id+'_wrapper').find('.wp-video').attr('style', 'width:'+set_width+'px; height:'+set_height+'px;');
535
}
536
@@ -553,7 +553,7 @@ function kgvid_resize_gallery_play_button(gallery_id) {
553
var video_vars = jQuery('#'+gallery_id+' .kgvid_video_gallery_thumb').first().data('kgvid_video_vars');
554
var thumb_width = jQuery('#'+gallery_id+' .kgvid_video_gallery_thumb').first().width();
555
556
- if ( video_vars.player_type == "Video.js" || video_vars.player_type == "WordPress Default" ) {
557
558
var max_percent = 0.17;
559
@@ -563,7 +563,7 @@ function kgvid_resize_gallery_play_button(gallery_id) {
563
var translate_y = 30;
564
}
565
566
- if ( video_vars.player_type == "WordPress Default" ) {
567
var button_selector = '.mejs-overlay-button';
568
var translate_y = 5;
569
}
135
if ( meta > 0 ) {
136
jQuery('#kgvid-simplemodal-container').css('color','white'); //show text if there's anything to see below the video
137
meta_bump = 5;
138
+ if ( video_vars.player_type == "JWPlayer" ) { meta_bump = 15; }
139
jQuery('#kgvid-simplemodal-container').height(jQuery('#kgvid-simplemodal-container').height() + meta_bump);
140
}
141
144
videojs('video_'+id).play();
145
}//end if Video.js
146
147
+ if ( video_vars.player_type == "WordPressDefault" ) {
148
jQuery('#kgvid_'+id+'_wrapper video').mediaelementplayer({
149
success: function(mediaElement, domObject) {
150
if (mediaElement.pluginType == 'flash' || mediaElement.pluginType == 'silverlight') {
178
videojs('video_'+id).pause();
179
setTimeout(function() { videojs('video_'+id).dispose(); }, 0);
180
}
181
+ if ( video_vars.player_type == "JWPlayer" ) {
182
jwplayer(jQuery('#kgvid_'+id+'_wrapper .jwplayer').attr('id')).stop();
183
}
184
}
339
340
} //end if Video.js
341
342
+ if ( video_vars.player_type == "Strobe Media Playback" || video_vars.player_type == "WordPressDefault" ) {
343
344
jQuery('#video_'+id+'_div').hover(
345
function(){
351
);
352
} //end if Strobe Media Playback
353
354
+ if ( video_vars.player_type == "WordPressDefault" ) {
355
356
player = jQuery('#video_'+id+'_div video');
357
392
393
} //end if WordPress Default
394
395
+ if ( video_vars.player_type == "JWPlayer" ) {
396
player_id = jQuery('#video_'+id+'_div').children('div[id^="jwplayer"]').attr('id');
397
var player = jwplayer(player_id);
398
530
jQuery('#video_'+id).attr('width',set_width).attr('height',set_height);
531
jQuery('#video_'+id+'_html5_api').attr('width',set_width).attr('height',set_height);
532
}
533
+ if ( video_vars.player_type == "WordPressDefault" ) {
534
jQuery('#kgvid_'+id+'_wrapper').find('.wp-video').attr('style', 'width:'+set_width+'px; height:'+set_height+'px;');
535
}
536
553
var video_vars = jQuery('#'+gallery_id+' .kgvid_video_gallery_thumb').first().data('kgvid_video_vars');
554
var thumb_width = jQuery('#'+gallery_id+' .kgvid_video_gallery_thumb').first().width();
555
556
+ if ( video_vars.player_type == "Video.js" || video_vars.player_type == "WordPressDefault" ) {
557
558
var max_percent = 0.17;
559
563
var translate_y = 30;
564
}
565
566
+ if ( video_vars.player_type == "WordPressDefault" ) {
567
var button_selector = '.mejs-overlay-button';
568
var translate_y = 5;
569
}
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
5
Requires at least: 3.5
6
Tested up to: 4.3
7
- Stable tag: 4.5.4
8
License: GPLv2 or later
9
License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
@@ -231,6 +231,10 @@ Enter the username & password in the plugin settings "FFMPEG Settings" tab, or u
231
232
== Changelog ==
233
234
= 4.5.4 - August 9, 2015 =
235
* Added option to disable native controls on mobile devices when using the Video.js player.
236
* Added Schema.org uploadDate and description tags which are required by Google for video listings.
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
5
Requires at least: 3.5
6
Tested up to: 4.3
7
+ Stable tag: 4.5.5
8
License: GPLv2 or later
9
License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
231
232
== Changelog ==
233
234
+ = 4.5.5 - August 20, 2015 =
235
+ * Fixed a number of potential infinite loops and other recursion issues related to longstanding WordPress bug <a href='https://core.trac.wordpress.org/ticket/17817'>#17817</a>.
236
+ * Changed video player names with spaces (WordPress Default, JW Player) to one word camel case for JavaScript functions (WordPressDefault, JWPlayer).
237
+
238
= 4.5.4 - August 9, 2015 =
239
* Added option to disable native controls on mobile devices when using the Video.js player.
240
* Added Schema.org uploadDate and description tags which are required by Google for video listings.
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.5.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.504,
63
"embed_method" => "Video.js",
64
"jw_player_id" => "",
65
"template" => false,
@@ -761,26 +761,6 @@ function kvid_readfile_chunked($file, $retbytes=TRUE) { //sends large files in c
761
762
}
763
764
- function kgvid_check_for_shortcode_in_content() {
765
- global $post;
766
- $pattern = get_shortcode_regex();
767
- preg_match_all( '/'. $pattern .'/s', $post->post_content, $matches );
768
- if ( is_array($matches) && array_key_exists( 2, $matches ) && array_key_exists( 5, $matches ) ) {
769
- foreach ( $matches[2] as $shortcode_index => $shortcode ) {
770
- if ( $shortcode == "KGVID" || $shortcode == "FMP" ) { continue; }
771
- else {
772
- foreach ( $matches as $match_index => $shortcode_matches ) {
773
- unset($matches[$match_index][$shortcode_index]);
774
- }
775
- }
776
- }
777
- foreach ( $matches[5] as $index => $url ) {
778
- if ( empty($url) ) { unset($matches[5][$index]); }
779
- }
780
- }
781
- return $matches;
782
- }
783
-
784
function kgvid_get_attachment_medium_url( $id )
785
{
786
$medium_array = image_downsize( $id, 'medium' );
@@ -1748,14 +1728,22 @@ function kgvid_gallery_page($page_number, $query_atts, $last_video_id = 0) {
1748
1749
$dimensions = kgvid_set_video_dimensions($attachment->ID, true);
1750
1751
- $shortcode = '[KGVID autoplay="true" id="'.$attachment->ID.'" width="'.$dimensions['width'].'" height="'.$dimensions['height'].'"';
1752
- if ($kgvid_postmeta['downloadlink'] == "on") { $shortcode .= ' downloadlink="true"'; }
1753
- $shortcode .= '][/KGVID]';
1754
1755
- $popup_code = do_shortcode($shortcode);
1756
preg_match('/data-kgvid_video_vars=.*? /', $popup_code, $video_vars);
1757
$popup_code = str_replace(array("\r", "\n", "\t", $video_vars[0]), "", $popup_code);
1758
- $video_vars[0] = str_replace('&nbsp;', ' ', $video_vars[0]);
1759
1760
if ( $options['js_skin'] == "" ) { $options['js_skin'] = "vjs-default-skin"; }
1761
if ( is_array($query_atts) && array_key_exists('skin', $query_atts) ) {
@@ -1791,6 +1779,7 @@ function kgvid_gallery_page($page_number, $query_atts, $last_video_id = 0) {
1791
} //if there are attachments
1792
1793
return $code;
1794
}
1795
1796
function kgvid_switch_gallery_page() {
@@ -1809,6 +1798,519 @@ function kgvid_switch_gallery_page() {
1809
add_action( 'wp_ajax_kgvid_switch_gallery_page', 'kgvid_switch_gallery_page' ); // ajax for logged in users
1810
add_action( 'wp_ajax_nopriv_kgvid_switch_gallery_page', 'kgvid_switch_gallery_page' ); // ajax for not logged in users
1811
1812
function kgvid_shortcode_atts($atts) {
1813
1814
$options = kgvid_get_options();
@@ -1917,17 +2419,11 @@ function kgvid_shortcode_atts($atts) {
1917
1918
function KGVID_shortcode($atts, $content = ''){
1919
1920
- global $content_width;
1921
- global $kgvid_video_id;
1922
- if ( !$kgvid_video_id ) { $kgvid_video_id = 0; }
1923
-
1924
- $content_width_save = $content_width;
1925
-
1926
$code = "";
1927
if ( !is_feed() ) {
1928
1929
$options = kgvid_get_options();
1930
- $id_array = array();
1931
kgvid_enqueue_shortcode_scripts();
1932
1933
if ( in_the_loop() ) { $post_ID = get_the_ID(); }
@@ -1937,496 +2433,7 @@ function KGVID_shortcode($atts, $content = ''){
1937
1938
if ( $query_atts["gallery"] != "true" ) { //if this is not a pop-up gallery
1939
1940
- $video_formats = kgvid_video_formats();
1941
-
1942
- if ( empty($content) ) {
1943
- if ( !empty($query_atts["id"]) ) {
1944
- $id_array[0] = $query_atts["id"];
1945
- }
1946
- elseif ( $post_ID != 1 ) {
1947
- $args = array(
1948
- 'numberposts' => $query_atts['videos'],
1949
- 'post_mime_type' => 'video',
1950
- 'post_parent' => $post_ID,
1951
- 'post_status' => null,
1952
- 'post_type' => 'attachment',
1953
- 'orderby' => $query_atts['orderby'],
1954
- 'order' => $query_atts['order']
1955
- );
1956
- $video_attachments = get_posts($args);
1957
- if ( $video_attachments ) {
1958
- foreach ( $video_attachments as $video ) {
1959
- $id_array[] = $video->ID;
1960
- }
1961
- }
1962
- else { return; } //if there are no video children of the current post
1963
- }
1964
- else { return; } //if there's no post ID and no $content
1965
- }
1966
- else { // $content is a URL
1967
- // workaround for relative video URL (contributed by Lee Fernandes)
1968
- if(substr($content, 0, 1) == '/') $content = get_bloginfo('url').$content;
1969
- $content = trim($content);
1970
- $id_array[0] = kgvid_url_to_id($content);
1971
- }
1972
-
1973
- $original_content = $content;
1974
-
1975
- foreach ( $id_array as $id ) { //loop through videos
1976
-
1977
- $div_suffix = 'kgvid_'.strval($kgvid_video_id);
1978
-
1979
- $query_atts = kgvid_shortcode_atts($atts); //reset values so they can be different with multiple videos
1980
- $content = $original_content;
1981
- $sources = array();
1982
- $mp4already = false;
1983
- $dimensions = array();
1984
-
1985
- $compatible = array("flv", "f4v", "mp4", "mov", "m4v", "ogv", "ogg", "webm");
1986
- $h264compatible = array("mp4", "mov", "m4v");
1987
-
1988
- if ( !empty($id) ) { //if the video is an attachment in the WordPress db
1989
-
1990
- $attachment_url = wp_get_attachment_url($id);
1991
- if ( $attachment_url == false ) { echo "Invalid video ID"; continue; }
1992
- $exempt_cdns = array('amazonaws.com', 'rackspace.com', 'netdna-cdn.com', 'nexcess-cdn.net', 'limelight.com'); //don't replace URLs that point to CDNs
1993
- $exempt_url = false;
1994
- foreach ( $exempt_cdns as $exempt_cdn ) {
1995
- if ( strpos($content, $exempt_cdn) !== false ) {
1996
- $exempt_url = true;
1997
- }
1998
- }
1999
- if ( !$exempt_url ) { $content = $attachment_url; }
2000
-
2001
- $encodevideo_info = kgvid_encodevideo_info($content, $id);
2002
- $attachment_info = get_post( $id );
2003
- $kgvid_postmeta = kgvid_get_attachment_meta($id);
2004
-
2005
- $dimensions = kgvid_set_video_dimensions($id);
2006
-
2007
- if ( empty($atts['width']) ) {
2008
- $query_atts['width'] = $dimensions['width'];
2009
- $query_atts['height'] = $dimensions['height'];
2010
- }
2011
-
2012
- $poster_id = get_post_meta($id, '_kgflashmediaplayer-poster-id', true);
2013
- if ( !empty($poster_id) ) {
2014
- $poster_image_src = wp_get_attachment_image_src($poster_id, 'full');
2015
- $query_atts['poster'] = $poster_image_src[0];
2016
- if ( strpos($query_atts['width'], '%') === false && intval($query_atts['width']) <= get_option('medium_size_h') ) {
2017
- $query_atts['poster'] = kgvid_get_attachment_medium_url($poster_id);
2018
- }
2019
- }
2020
-
2021
- if ( $query_atts['title'] == "true" ) {
2022
- $query_atts['title'] = $attachment_info->post_title;
2023
- $stats_title = $query_atts['title'];
2024
- }
2025
- else { $stats_title = $attachment_info->post_title; }
2026
- if ( empty($query_atts['caption']) ) { $query_atts['caption'] = $attachment_info->post_excerpt; }
2027
- if ( empty($query_atts['description']) ) { $query_atts['description'] = $attachment_info->post_content; }
2028
-
2029
- $countable = true;
2030
- }
2031
- else { //video is not in the database
2032
-
2033
- $encodevideo_info = kgvid_encodevideo_info($content, $post_ID); //send the id of the post the video's embedded in
2034
- if ( $query_atts['title'] == "true" ) {
2035
- $query_atts['title'] = "false";
2036
- }
2037
- $stats_title = basename($content);
2038
- if ( $query_atts['embedcode'] == "true" ) {
2039
- $query_atts['embedcode'] = "false"; //can't use embed code with videos that are not in the database
2040
- }
2041
-
2042
- $countable = false;
2043
- }
2044
-
2045
- $mime_type_check = wp_check_filetype($content);
2046
- if ( in_array($mime_type_check['ext'], $h264compatible) ) {
2047
- $format_type = "h264";
2048
- $mime_type = "video/mp4";
2049
- }
2050
- else {
2051
- $format_type = $mime_type_check['ext'];
2052
- $mime_type = $mime_type_check['type'];
2053
- }
2054
-
2055
- unset($video_formats['fullres']);
2056
- $video_formats = array('original' => array( "type" => $format_type, "mime" => $mime_type, "name" => "Full", "label" => "Full" ) ) + $video_formats;
2057
-
2058
- if ( in_array($mime_type_check['ext'], $compatible) ) {
2059
-
2060
- $encodevideo_info["original"]["exists"] = true;
2061
- $encodevideo_info["original"]["url"] = $content;
2062
-
2063
- if ( is_array($dimensions) && array_key_exists('actualheight', $dimensions) ) {
2064
- $video_formats['original']['label'] = $dimensions['actualheight'].'p';
2065
- $video_formats['original']['height'] = $dimensions['actualheight'];
2066
- $encodevideo_info["original"]["height"] = $dimensions['actualheight'];
2067
- }
2068
-
2069
- }
2070
- else { $encodevideo_info["original"]["exists"] = false; }
2071
-
2072
- if($query_atts["endofvideooverlaysame"] == "true") { $query_atts["endofvideooverlay"] = $query_atts["poster"]; }
2073
-
2074
- if ( $options['embed_method'] == "Strobe Media Playback" ) {
2075
-
2076
- $flash_settings = kgvid_generate_flashvars($content, $query_atts, $encodevideo_info, $div_suffix);
2077
-
2078
- } //if Strobe Media Playback
2079
-
2080
- if ( $query_atts['inline'] == "true" ) {
2081
- $aligncode = ' kgvid_wrapper_inline';
2082
- if ( $query_atts['align'] == "left" ) { $aligncode .= ' kgvid_wrapper_inline_left'; }
2083
- if ( $query_atts['align'] == "center" ) { $aligncode .= ' kgvid_wrapper_auto_left kgvid_wrapper_auto_right'; }
2084
- if ( $query_atts['align'] == "right" ) { $aligncode .= ' kgvid_wrapper_inline_right'; }
2085
- }
2086
- else {
2087
- if ( $query_atts['align'] == "left" ) { $aligncode = ''; }
2088
- if ( $query_atts['align'] == "center" ) { $aligncode = ' kgvid_wrapper_auto_left kgvid_wrapper_auto_right'; }
2089
- if ( $query_atts['align'] == "right" ) { $aligncode = ' kgvid_wrapper_auto_left'; }
2090
- }
2091
-
2092
- if ( ( $query_atts['title'] != "false" && $options['embed_method'] != "JW Player" )
2093
- || $query_atts['embedcode'] != "false" ) { //generate content overlaid on video
2094
- $kgvid_meta = true;
2095
- }
2096
- else { $kgvid_meta = false; }
2097
-
2098
- $video_variables = array(
2099
- 'id' => $div_suffix,
2100
- 'attachment_id' => $id,
2101
- 'player_type' => str_replace(' ', '&nbsp;', $options['embed_method']),
2102
- 'width' => $query_atts['width'],
2103
- 'height' => $query_atts['height'],
2104
- 'fullwidth' => $query_atts['fullwidth'],
2105
- 'countable' => $countable,
2106
- 'autoplay' => $query_atts['autoplay'],
2107
- 'set_volume' => $query_atts['volume'],
2108
- 'mute' => $query_atts['mute'],
2109
- 'meta' => $kgvid_meta,
2110
- 'endofvideooverlay' => $query_atts['endofvideooverlay'],
2111
- 'resize' => $query_atts['resize'],
2112
- 'auto_res' => $query_atts['auto_res'],
2113
- 'right_click' => $query_atts['right_click']
2114
- );
2115
-
2116
- if ( $options['embed_method'] == "Strobe Media Playback" && $flash_settings['flash_source_found'] ) {
2117
-
2118
- $video_variables['swfurl'] = plugins_url('', __FILE__)."/flash/StrobeMediaPlayback.swf";
2119
- $video_variables['expressinstallswfurl'] = plugins_url("", __FILE__)."/flash/expressInstall.swf";
2120
- $video_variables['flashvars'] = $flash_settings['flashvars'];
2121
- $video_variables['params'] = $flash_settings['params'];
2122
-
2123
- } //if Strobe Media
2124
-
2125
- $video_variables = str_replace('&nbsp;', ' ', $video_variables);
2126
- $code .= '<div id="kgvid_'.$div_suffix.'_wrapper" class="kgvid_wrapper'.$aligncode.'">'."\n\t\t\t";
2127
- $code .= '<div id="video_'.$div_suffix.'_div" class="fitvidsignore kgvid_videodiv" data-id="'.$div_suffix.'" data-kgvid_video_vars="'.esc_attr(json_encode($video_variables)).'" itemprop="video" itemscope itemtype="https://schema.org/VideoObject">';
2128
- if ( $query_atts["poster"] != '' ) { $code .= '<meta itemprop="thumbnailUrl" content="'.esc_attr($query_atts["poster"]).'" />'; }
2129
- if ( !empty($id) ) { $schema_embedURL = site_url('/')."?attachment_id=".$id."&amp;kgvid_video_embed[enable]=true"; }
2130
- else { $schema_embedURL = $content; }
2131
- $code .= '<meta itemprop="embedUrl" content="'.esc_attr($schema_embedURL).'" />';
2132
- $code .= '<meta itemprop="contentUrl" content="'.$content.'" />';
2133
-
2134
- if ( !empty($query_atts['title']) ) { $code .= '<meta itemprop="name" content="'.esc_attr($query_atts['title']).'" />'; }
2135
-
2136
- if ( !empty($query_atts['description']) ) { $description = $query_atts['description']; }
2137
- elseif ( !empty($query_atts['caption']) ) { $description = $query_atts['caption']; }
2138
- elseif ( in_the_loop() && !is_attachment() ) { $description = get_the_excerpt(); }
2139
- if ( empty($description) ) { $description = __('Video', 'video-embed-thumbnail-generator'); }
2140
- $code .= '<meta itemprop="description" content="'.esc_attr($description).'" />';
2141
-
2142
- if ( !empty($id) ) { $upload_date = get_the_date('c', $id); }
2143
- elseif ( $post_ID != 1 ) { $upload_date = get_the_date('c', $post_ID); }
2144
- else { $upload_date = current_time('c'); }
2145
- $code .= '<meta itemprop="uploadDate" content="'.esc_attr($upload_date).'" />';
2146
-
2147
- $track_keys = array('kind', 'srclang', 'src', 'label', 'default');
2148
- if ( !isset($kgvid_postmeta) || ( is_array($kgvid_postmeta) && !is_array($kgvid_postmeta['track']) ) ) {
2149
- $kgvid_postmeta['track'] = array();
2150
- $kgvid_postmeta['track'][0] = array ( 'kind' => '', 'srclang' => '', 'src' => '', 'label' => '', 'default' => '');
2151
- }
2152
- foreach ( $track_keys as $key ) {
2153
- if ( empty($kgvid_postmeta['track'][0][$key]) ) { $kgvid_postmeta['track'][0][$key] = $query_atts['track_'.$key]; }
2154
- }
2155
-
2156
- $track_code = "";
2157
- if ( !empty($kgvid_postmeta['track'][0]['src']) ) {
2158
- foreach ( $kgvid_postmeta['track'] as $track => $track_attribute ) {
2159
- foreach ( $track_attribute as $attribute => $value ) {
2160
- if ( empty($value) ) { $track_attribute[$attribute] = $query_atts['track_'.$attribute]; }
2161
- }
2162
- if ( $options['embed_method'] == "WordPress Default" && $track_attribute['kind'] == 'captions' ) { $track_attribute['kind'] = 'subtitles'; }
2163
- $track_code .= "\t\t\t\t\t<track id='".$div_suffix."_text_".$track."' kind='".esc_attr($track_attribute['kind'])."' src='".esc_attr($track_attribute['src'])."' srclang='".esc_attr($track_attribute['srclang'])."' label='".esc_attr($track_attribute['label'])."' ".esc_attr($track_attribute['default'])." />\n";
2164
- }
2165
- }
2166
-
2167
- if ( $options['embed_method'] == "WordPress Default" ) {
2168
- $wp_shortcode = "[video ";
2169
- $sources_hack = "";
2170
- foreach ($video_formats as $format => $format_stats) {
2171
- if ( $format != "original" && $encodevideo_info[$format]["url"] == $content ) { unset($sources['original']); }
2172
- if ( $encodevideo_info[$format]["exists"] ) {
2173
- if ( $format_stats['type'] != "h264" || !$mp4already ) {
2174
- $shortcode_type = wp_check_filetype( $encodevideo_info[$format]["url"], wp_get_mime_types() );
2175
- $sources[$format] = $shortcode_type['ext'].'="'.$encodevideo_info[$format]["url"].'" ';
2176
- if ( $format_stats['type'] == "h264" ) { //WordPress built-in shortcode doesn't support multiple videos of the same type but we'll hack it in later
2177
- $mp4already = true;
2178
- }
2179
- }
2180
- else { $sources_hack .= '<source type="'.$format_stats['mime'].'" src="'.esc_attr($encodevideo_info[$format]["url"]).'" />'; }
2181
- }
2182
- }
2183
-
2184
- $wp_shortcode .= implode($sources);
2185
- if ( $query_atts["poster"] != '' ) { $wp_shortcode .= 'poster="'.esc_attr($query_atts["poster"]).'" '; }
2186
- $wp_shortcode .= 'width='.$query_atts["width"].' height='.$query_atts["height"].' ';
2187
- if ( $query_atts["loop"] == 'true') { $wp_shortcode .= 'loop="true" '; }
2188
- if ( $query_atts["autoplay"] == 'true') { $wp_shortcode .= 'autoplay="true" '; }
2189
- $wp_shortcode .= 'preload="'.$options['preload'].'"';
2190
- $wp_shortcode .= "]";
2191
- $content_width = $query_atts['width'];
2192
- $executed_shortcode = do_shortcode($wp_shortcode);
2193
- $content_width = $content_width_save;
2194
- if ( $sources_hack ) { //insert remaining mp4 sources manually
2195
- $position = strpos($executed_shortcode, '<a href=');
2196
- $executed_shortcode = substr_replace( $executed_shortcode, $sources_hack, $position, 0 );
2197
- }
2198
- if ( !empty($track_code) ) { //insert track code manually
2199
- $position = strpos($executed_shortcode, '</video>');
2200
- $executed_shortcode = substr_replace( $executed_shortcode, $track_code, $position, 0 );
2201
- }
2202
- $code .= $executed_shortcode;
2203
- }
2204
-
2205
- if ( $options['embed_method'] == "JW Player" ) {
2206
-
2207
- if ( class_exists('JWP6_Shortcode') ) {
2208
-
2209
- $x = 0;
2210
- foreach ($video_formats as $format => $format_stats) {
2211
- if ( $format != "original" && $encodevideo_info[$format]["url"] == $content ) { unset($sources['original']); }
2212
- if ( $encodevideo_info[$format]["exists"] ) {
2213
- if ( array_key_exists('height', $encodevideo_info[$format]) ) {
2214
- $source_key = $encodevideo_info[$format]['height'];
2215
- $format_stats['label'] = $encodevideo_info[$format]['height'].'p';
2216
- }
2217
- else { $source_key = $x; }
2218
-
2219
- $sources[$source_key] = '{ file:\''.esc_attr($encodevideo_info[$format]["url"]).'\', label:\''.$format_stats['label'].'\'';
2220
- if ( $format == "original" ) { $sources[$source_key] .= ', default:\'true\''; }
2221
- $sources[$source_key] .= '}';
2222
- $x++;
2223
- }
2224
- }
2225
- krsort($sources);
2226
-
2227
- $jw_tracks = array();
2228
- if ( !empty($kgvid_postmeta['track'][0]['src']) ) {
2229
- foreach ( $kgvid_postmeta['track'] as $track => $track_attribute ) {
2230
- foreach ( $track_attribute as $attribute => $value ) {
2231
- if ( empty($value) ) { $track_attribute[$attribute] = $query_atts['track_'.$attribute]; }
2232
- }
2233
- $default_text = '';
2234
- if ( $track_attribute['default'] == 'default' ) { $default_text = ', \'default\': true'; }
2235
- $jw_tracks[] = '{ file:\''.esc_attr($track_attribute['src']).'\', kind:\''.esc_attr($track_attribute['kind']).'\', label:\''.esc_attr($track_attribute['label']).'\''.$default_text.'}';
2236
- }
2237
- }
2238
-
2239
- $jw_shortcode = "[jwplayer ";
2240
- $jw_shortcode .= 'sources="'.implode(',', $sources).'" ';
2241
- $jw_shortcode .= 'tracks="'.implode(',', $jw_tracks).'" ';
2242
- if ( $query_atts["poster"] != '' ) { $jw_shortcode .= 'image="'.esc_attr($query_atts["poster"]).'" '; }
2243
- if ( $query_atts["loop"] == 'true' ) { $jw_shortcode .= 'repeat="true" '; }
2244
- if ( $query_atts["autoplay"] == 'true' ) { $jw_shortcode .= 'autostart="true" '; }
2245
- if ( $query_atts["controlbar"] == 'none') { $jw_shortcode .= 'controls="false" '; }
2246
- if ( $query_atts['title'] != "false" ) { $jw_shortcode .= ' title="'.$query_atts['title'].'" '; }
2247
- if ( $options['jw_player_id'] != "") {
2248
- $jw_player_config = get_option('jwp6_player_config_'.$options['jw_player_id']);
2249
- if ( !empty($jw_player_config) ) { $jw_shortcode .= ' player="'.$options['jw_player_id'].'" '; }
2250
- }
2251
-
2252
- if ( !empty($query_atts['custom_atts']) && is_array($query_atts['custom_atts']) ) {
2253
- foreach ( $query_atts['custom_atts'] as $jw_param => $jw_setting ) {
2254
- $jw_shortcode .= ' '.$jw_param.'="'.$jw_setting.'" ';
2255
- }
2256
- }
2257
-
2258
- $jw_shortcode = trim($jw_shortcode);
2259
- $jw_shortcode .= ']';
2260
-
2261
- $executed_shortcode = do_shortcode($jw_shortcode); //just in case the shortcode is active
2262
- //this is JW Player's hack for executing without registering a WP shortcode
2263
- $tag_regex = '/(.?)\[(jwplayer)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?(.?)/s';
2264
- $executed_shortcode = preg_replace_callback($tag_regex, array("JWP6_Shortcode", "tag_parser"), $jw_shortcode);
2265
-
2266
- $code .= $executed_shortcode;
2267
-
2268
- }// if class exists
2269
- else { $options['embed_method'] = "Video.js"; }
2270
-
2271
- }
2272
-
2273
- if ( $options['embed_method'] == "Video.js" || $options['embed_method'] == "Strobe Media Playback" ) {
2274
-
2275
- $enable_resolutions_plugin = false;
2276
- $x = 20;
2277
- $h264_resolutions = array();
2278
-
2279
- foreach ($video_formats as $format => $format_stats) {
2280
- if ( $format != "original" && $encodevideo_info[$format]["url"] == $content ) { unset($sources['original']); }
2281
- if ( $encodevideo_info[$format]["exists"] ) {
2282
-
2283
- if ( array_key_exists('height', $encodevideo_info[$format]) && $format_stats['type'] == 'h264' ) {
2284
- $source_key = $encodevideo_info[$format]['height'];
2285
- $format_stats['label'] = $encodevideo_info[$format]['height'].'p';
2286
- }
2287
- else { $source_key = $x; }
2288
-
2289
- $sources[$source_key] = "\t\t\t\t\t".'<source src="'.esc_attr($encodevideo_info[$format]["url"]).'?id='.$kgvid_video_id.'" type="'.$format_stats["mime"].'"';
2290
- if ( $format == 'vp9' ) { $sources[$source_key] .= ' codecs="vp9, vorbis"'; }
2291
- if ( $format_stats['type'] == 'h264' ) {
2292
- $sources[$source_key] .= ' data-res="'.$format_stats['label'].'"';
2293
- if ( $mp4already ) { //there is more than one resolution available
2294
- $enable_resolutions_plugin = true;
2295
- }
2296
- $mp4already = true;
2297
- $h264_resolutions[] = $format_stats['label'];
2298
- }
2299
- else { $sources[$source_key] .= ' data-res="'.$format_stats['name'].'"'; }
2300
- $sources[$source_key] .= '>'."\n";
2301
- }
2302
- $x--;
2303
- }
2304
- krsort($sources);
2305
- natsort($h264_resolutions);
2306
-
2307
- $code .= '<video id="video_'.$div_suffix.'" ';
2308
- if ( $query_atts["loop"] == 'true') { $code .= 'loop '; }
2309
- if ( $query_atts["autoplay"] == 'true') { $code .= 'autoplay '; }
2310
- if ( $query_atts["controlbar"] != 'none') { $code .= 'controls '; }
2311
- $code .= 'preload="'.$options['preload'].'" ';
2312
- if ( $query_atts["poster"] != '' ) { $code .= 'poster="'.esc_attr($query_atts["poster"]).'" '; }
2313
- $code .= 'width="'.$query_atts["width"].'" height="'.esc_attr($query_atts["height"]).'"';
2314
- $locale = get_locale();
2315
- if ( $options['js_skin'] == "" ) { $options['js_skin'] = "vjs-default-skin"; }
2316
- if ( is_array($atts) && array_key_exists('skin', $atts) ) {
2317
- $options['js_skin'] = $atts['skin']; //allows user to set skin for individual videos using the skin="" attribute
2318
- }
2319
- $code .= ' class="fitvidsignore '.esc_attr('video-js '.$options['js_skin']).'" data-setup=\'{ ';
2320
- if ( $options['nativecontrolsfortouch'] == "on" ) { $code .= '"nativeControlsForTouch": true, '; }
2321
- $code .= '"language": "'.substr($locale, 0, 2).'"';
2322
- if ( $enable_resolutions_plugin ) { $code .= ', "plugins" : { "resolutionSelector" : { "force_types" : ["video/mp4"]';
2323
- if ( $query_atts["auto_res"] == "highest" ) { $code .= ', "default_res": "'.end($h264_resolutions).'"'; }
2324
- if ( $query_atts["auto_res"] == "lowest" ) { $code .= ', "default_res": "'.reset($h264_resolutions).'"'; }
2325
- $code .= ' } }';
2326
- }
2327
- $code .= ' }\'';
2328
- $code .= ">\n";
2329
-
2330
- $code .= implode("", $sources); //add the <source> tags created earlier
2331
- $code .= $track_code; //if there's a text track
2332
- $code .= "\t\t\t\t</video>\n";
2333
-
2334
- }
2335
- $code .= "\t\t\t</div>\n";
2336
- $show_views = false;
2337
- if ( !empty($id) || !empty($query_atts['caption']) || $query_atts['downloadlink'] == "true" || $content == plugins_url('/images/sample-video-h264.mp4', __FILE__) ) { //generate content below the video
2338
- if ( is_array($kgvid_postmeta) && array_key_exists('starts', $kgvid_postmeta) ) { $view_count = number_format(intval($kgvid_postmeta['starts'])); }
2339
- else { $view_count = "0"; }
2340
- if ( $content == plugins_url('/images/sample-video-h264.mp4', __FILE__) ) { $view_count = "XX"; }
2341
- if ( $query_atts['view_count'] == "true" ) { $show_views = true; }
2342
- if ( !empty($query_atts['caption']) || $show_views || $query_atts['downloadlink'] == "true" ) {
2343
- $code .= "\t\t\t".'<div class="kgvid_below_video" id="video_'.$div_suffix.'_below">';
2344
- if ( $show_views ) { $code .= '<div class="kgvid-viewcount" id="video_'.$div_suffix.'_viewcount">'.sprintf( _n( '%s view', '%s views', intval(str_replace(',', '', $view_count)) , 'video-embed-thumbnail-generator'), $view_count ).'</div>'; }
2345
- if ( !empty($query_atts['caption']) || $query_atts['downloadlink'] == "true" ) {
2346
- $code .= '<div class="kgvid-caption" id="video_'.$div_suffix.'_caption">'.$query_atts['caption'];
2347
- if ( $query_atts['downloadlink'] == "true" ) {
2348
- if ( !empty($query_atts['caption']) ) { $code .= '<br>'; }
2349
- $forceable = false;
2350
- if ( !empty($id) && $options['click_download'] == 'on' ) {
2351
- $filepath = get_attached_file($id);
2352
- if ( file_exists($filepath) ) {
2353
- $forceable = true;
2354
- $code .= '<a href="'.site_url('/').'?attachment_id='.$id.'&kgvid_video_embed[download]=true">'.__('Click on this link to download', 'video-embed-thumbnail-generator').'</a>';
2355
- }
2356
- }
2357
- if ( !$forceable ) { $code .= '<a href="'.$content.'">'.__('Right-click or ctrl-click on this link to download', 'video-embed-thumbnail-generator').'</a>'; }
2358
- }
2359
- $code .= '</div>';
2360
- }
2361
- $code .= '</div>';
2362
- }
2363
- }
2364
-
2365
- if ( $kgvid_meta == true ) { //generate content overlaid on video
2366
- $code .= "\t\t\t<div style=\"display:none;\" id=\"video_".$div_suffix."_meta\" class=\"kgvid_video_meta kgvid_video_meta_hover\">\n";
2367
- if ( $query_atts['embedcode'] != "false" ) {
2368
- if ( $query_atts['embedcode'] == "true" ) { $iframeurl = site_url('/')."?attachment_id=".$id."&amp;kgvid_video_embed[enable]=true"; }
2369
- else { $iframeurl = $query_atts['embedcode']; }
2370
- $iframecode = "<iframe allowfullscreen src='".$iframeurl."' frameborder='0' scrolling='no' width='".esc_attr($query_atts['width'])."' height='".esc_attr($query_atts["height"])."'></iframe>";
2371
- $code .= "\t\t\t\t<div id=\"video_".$div_suffix."_embed\" class=\"kgvid_share\"><span>"._x('Embed:', 'precedes code for embedding video', 'video-embed-thumbnail-generator')." </span><input type=\"text\" value=\"".esc_attr($iframecode)."\" onClick=\"this.select();\"></div>\n";
2372
- }
2373
- if ( $query_atts['title'] != "false" && $options['embed_method'] != "JW Player" ) {
2374
- $code .= "\t\t\t\t<div id='video_".$div_suffix."_title' class='kgvid_title'>".$query_atts['title']."</div>\n";
2375
- }
2376
- $code .= "\t\t\t</div>\n";
2377
- }
2378
-
2379
- if ( !empty($query_atts["watermark"]) && $query_atts["watermark"] != "false" ) {
2380
- $watermark_id = kgvid_url_to_id($query_atts["watermark"]);
2381
- if ( $watermark_id ) { $query_atts["watermark"] = wp_get_attachment_url($watermark_id); }
2382
- $code .= "<div style=\"display:none;\" id='video_".$div_suffix."_watermark' class='kgvid_watermark'>";
2383
- if ( !empty($query_atts["watermark_url"]) && $query_atts["watermark_link_to"] != 'custom' ) { $query_atts["watermark_link_to"] = 'custom'; }
2384
- if ( $query_atts['watermark_link_to'] != 'false' && $query_atts["watermark_url"] != 'false' ) {
2385
- $watermark_link = true;
2386
- switch ( $query_atts['watermark_link_to'] ) {
2387
-
2388
- case 'home':
2389
- $watermark_href = get_home_url();
2390
- break;
2391
-
2392
- case 'parent':
2393
- if ( !empty($id) && is_object($attachment_info) && array_key_exists('post_parent', $attachment_info) && !empty($attachment_info->post_parent) ) {
2394
- $watermark_href = get_permalink($attachment_info->post_parent);
2395
- }
2396
- else { $watermark_href = get_home_url(); }
2397
- break;
2398
-
2399
- case 'attachment':
2400
- if ( !empty($id) ) {
2401
- $watermark_href = get_permalink($id);
2402
- }
2403
- else { $watermark_href = get_home_url(); }
2404
- break;
2405
-
2406
- case 'download':
2407
- if ( !empty($id) ) {
2408
- $watermark_href = site_url('/').'?attachment_id='.$id.'&kgvid_video_embed[download]=true';
2409
- }
2410
- else { $watermark_href = $content; }
2411
- break;
2412
-
2413
- case 'custom':
2414
- $watermark_href = $query_atts["watermark_url"];
2415
- break;
2416
-
2417
- }
2418
- $code .= "<a target='_parent' href='".$watermark_href."'>";
2419
- }
2420
- else { $watermark_link = false; }
2421
- $code .= "<img src='".esc_attr($query_atts["watermark"])."' alt='watermark'>";
2422
- if ( $watermark_link ) { $code .= "</a>"; }
2423
- $code .= "</div>";
2424
- } //generate watermark
2425
- $code .= "\t\t</div>"; //end kgvid_XXXX_wrapper div
2426
-
2427
- $kgvid_video_id++;
2428
-
2429
- } //end id_array loop
2430
2431
} //if not gallery
2432
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.5.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.505,
63
"embed_method" => "Video.js",
64
"jw_player_id" => "",
65
"template" => false,
761
762
}
763
764
function kgvid_get_attachment_medium_url( $id )
765
{
766
$medium_array = image_downsize( $id, 'medium' );
1728
1729
$dimensions = kgvid_set_video_dimensions($attachment->ID, true);
1730
1731
+ $atts = array(
1732
+ 'autoplay' => 'true',
1733
+ 'id' => $attachment->ID,
1734
+ 'width' => $dimensions['width'],
1735
+ 'height' => $dimensions['height']
1736
+ );
1737
+ if ( $kgvid_postmeta['downloadlink'] == "on" ) { $atts['downloadlink'] = "true"; }
1738
+
1739
+ $popup_atts = kgvid_shortcode_atts($atts);
1740
+ if ( in_the_loop() ) { $post_ID = get_the_ID(); }
1741
+ else { $post_ID = 1; }
1742
+ $content = '';
1743
+ $popup_code = kgvid_single_video_code($popup_atts, $atts, $content, $post_ID);
1744
1745
preg_match('/data-kgvid_video_vars=.*? /', $popup_code, $video_vars);
1746
$popup_code = str_replace(array("\r", "\n", "\t", $video_vars[0]), "", $popup_code);
1747
1748
if ( $options['js_skin'] == "" ) { $options['js_skin'] = "vjs-default-skin"; }
1749
if ( is_array($query_atts) && array_key_exists('skin', $query_atts) ) {
1779
} //if there are attachments
1780
1781
return $code;
1782
+
1783
}
1784
1785
function kgvid_switch_gallery_page() {
1798
add_action( 'wp_ajax_kgvid_switch_gallery_page', 'kgvid_switch_gallery_page' ); // ajax for logged in users
1799
add_action( 'wp_ajax_nopriv_kgvid_switch_gallery_page', 'kgvid_switch_gallery_page' ); // ajax for not logged in users
1800
1801
+ function kgvid_single_video_code($query_atts, $atts, $content, $post_ID) {
1802
+
1803
+ global $content_width;
1804
+ $content_width_save = $content_width;
1805
+
1806
+ global $kgvid_video_id;
1807
+ if ( !$kgvid_video_id ) { $kgvid_video_id = 0; }
1808
+
1809
+ $options = kgvid_get_options();
1810
+ $code = "";
1811
+ $id_array = array();
1812
+ $video_formats = kgvid_video_formats();
1813
+
1814
+ if ( empty($content) ) {
1815
+ if ( !empty($query_atts["id"]) ) {
1816
+ $id_array[0] = $query_atts["id"];
1817
+ }
1818
+ elseif ( $post_ID != 1 ) {
1819
+ $args = array(
1820
+ 'numberposts' => $query_atts['videos'],
1821
+ 'post_mime_type' => 'video',
1822
+ 'post_parent' => $post_ID,
1823
+ 'post_status' => null,
1824
+ 'post_type' => 'attachment',
1825
+ 'orderby' => $query_atts['orderby'],
1826
+ 'order' => $query_atts['order']
1827
+ );
1828
+ $video_attachments = get_posts($args);
1829
+ if ( $video_attachments ) {
1830
+ foreach ( $video_attachments as $video ) {
1831
+ $id_array[] = $video->ID;
1832
+ }
1833
+ }
1834
+ else { return; } //if there are no video children of the current post
1835
+ }
1836
+ else { return; } //if there's no post ID and no $content
1837
+ }
1838
+ else { // $content is a URL
1839
+ // workaround for relative video URL (contributed by Lee Fernandes)
1840
+ if(substr($content, 0, 1) == '/') $content = get_bloginfo('url').$content;
1841
+ $content = trim($content);
1842
+ $id_array[0] = kgvid_url_to_id($content);
1843
+ }
1844
+
1845
+ $original_content = $content;
1846
+
1847
+ foreach ( $id_array as $id ) { //loop through videos
1848
+
1849
+ $div_suffix = 'kgvid_'.strval($kgvid_video_id);
1850
+
1851
+ $query_atts = kgvid_shortcode_atts($atts); //reset values so they can be different with multiple videos
1852
+ $content = $original_content;
1853
+ $sources = array();
1854
+ $mp4already = false;
1855
+ $dimensions = array();
1856
+
1857
+ $compatible = array("flv", "f4v", "mp4", "mov", "m4v", "ogv", "ogg", "webm");
1858
+ $h264compatible = array("mp4", "mov", "m4v");
1859
+
1860
+ if ( !empty($id) ) { //if the video is an attachment in the WordPress db
1861
+
1862
+ $attachment_url = wp_get_attachment_url($id);
1863
+ if ( $attachment_url == false ) { echo "Invalid video ID"; continue; }
1864
+ $exempt_cdns = array('amazonaws.com', 'rackspace.com', 'netdna-cdn.com', 'nexcess-cdn.net', 'limelight.com'); //don't replace URLs that point to CDNs
1865
+ $exempt_url = false;
1866
+ foreach ( $exempt_cdns as $exempt_cdn ) {
1867
+ if ( strpos($content, $exempt_cdn) !== false ) {
1868
+ $exempt_url = true;
1869
+ }
1870
+ }
1871
+ if ( !$exempt_url ) { $content = $attachment_url; }
1872
+
1873
+ $encodevideo_info = kgvid_encodevideo_info($content, $id);
1874
+ $attachment_info = get_post( $id );
1875
+ $kgvid_postmeta = kgvid_get_attachment_meta($id);
1876
+
1877
+ $dimensions = kgvid_set_video_dimensions($id);
1878
+
1879
+ if ( empty($atts['width']) ) {
1880
+ $query_atts['width'] = $dimensions['width'];
1881
+ $query_atts['height'] = $dimensions['height'];
1882
+ }
1883
+
1884
+ $poster_id = get_post_meta($id, '_kgflashmediaplayer-poster-id', true);
1885
+ if ( !empty($poster_id) ) {
1886
+ $poster_image_src = wp_get_attachment_image_src($poster_id, 'full');
1887
+ $query_atts['poster'] = $poster_image_src[0];
1888
+ if ( strpos($query_atts['width'], '%') === false && intval($query_atts['width']) <= get_option('medium_size_h') ) {
1889
+ $query_atts['poster'] = kgvid_get_attachment_medium_url($poster_id);
1890
+ }
1891
+ }
1892
+
1893
+ if ( $query_atts['title'] == "true" ) {
1894
+ $query_atts['title'] = $attachment_info->post_title;
1895
+ $stats_title = $query_atts['title'];
1896
+ }
1897
+ else { $stats_title = $attachment_info->post_title; }
1898
+ if ( empty($query_atts['caption']) ) { $query_atts['caption'] = $attachment_info->post_excerpt; }
1899
+ if ( empty($query_atts['description']) ) { $query_atts['description'] = $attachment_info->post_content; }
1900
+
1901
+ $countable = true;
1902
+ }
1903
+ else { //video is not in the database
1904
+
1905
+ $encodevideo_info = kgvid_encodevideo_info($content, $post_ID); //send the id of the post the video's embedded in
1906
+ if ( $query_atts['title'] == "true" ) {
1907
+ $query_atts['title'] = "false";
1908
+ }
1909
+ $stats_title = basename($content);
1910
+ if ( $query_atts['embedcode'] == "true" ) {
1911
+ $query_atts['embedcode'] = "false"; //can't use embed code with videos that are not in the database
1912
+ }
1913
+
1914
+ $countable = false;
1915
+ }
1916
+
1917
+ $mime_type_check = wp_check_filetype($content);
1918
+ if ( in_array($mime_type_check['ext'], $h264compatible) ) {
1919
+ $format_type = "h264";
1920
+ $mime_type = "video/mp4";
1921
+ }
1922
+ else {
1923
+ $format_type = $mime_type_check['ext'];
1924
+ $mime_type = $mime_type_check['type'];
1925
+ }
1926
+
1927
+ unset($video_formats['fullres']);
1928
+ $video_formats = array('original' => array( "type" => $format_type, "mime" => $mime_type, "name" => "Full", "label" => "Full" ) ) + $video_formats;
1929
+
1930
+ if ( in_array($mime_type_check['ext'], $compatible) ) {
1931
+
1932
+ $encodevideo_info["original"]["exists"] = true;
1933
+ $encodevideo_info["original"]["url"] = $content;
1934
+
1935
+ if ( is_array($dimensions) && array_key_exists('actualheight', $dimensions) ) {
1936
+ $video_formats['original']['label'] = $dimensions['actualheight'].'p';
1937
+ $video_formats['original']['height'] = $dimensions['actualheight'];
1938
+ $encodevideo_info["original"]["height"] = $dimensions['actualheight'];
1939
+ }
1940
+
1941
+ }
1942
+ else { $encodevideo_info["original"]["exists"] = false; }
1943
+
1944
+ if($query_atts["endofvideooverlaysame"] == "true") { $query_atts["endofvideooverlay"] = $query_atts["poster"]; }
1945
+
1946
+ if ( $options['embed_method'] == "Strobe Media Playback" ) {
1947
+
1948
+ $flash_settings = kgvid_generate_flashvars($content, $query_atts, $encodevideo_info, $div_suffix);
1949
+
1950
+ } //if Strobe Media Playback
1951
+
1952
+ if ( $query_atts['inline'] == "true" ) {
1953
+ $aligncode = ' kgvid_wrapper_inline';
1954
+ if ( $query_atts['align'] == "left" ) { $aligncode .= ' kgvid_wrapper_inline_left'; }
1955
+ if ( $query_atts['align'] == "center" ) { $aligncode .= ' kgvid_wrapper_auto_left kgvid_wrapper_auto_right'; }
1956
+ if ( $query_atts['align'] == "right" ) { $aligncode .= ' kgvid_wrapper_inline_right'; }
1957
+ }
1958
+ else {
1959
+ if ( $query_atts['align'] == "left" ) { $aligncode = ''; }
1960
+ if ( $query_atts['align'] == "center" ) { $aligncode = ' kgvid_wrapper_auto_left kgvid_wrapper_auto_right'; }
1961
+ if ( $query_atts['align'] == "right" ) { $aligncode = ' kgvid_wrapper_auto_left'; }
1962
+ }
1963
+
1964
+ if ( ( $query_atts['title'] != "false" && $options['embed_method'] != "JW Player" )
1965
+ || $query_atts['embedcode'] != "false" ) { //generate content overlaid on video
1966
+ $kgvid_meta = true;
1967
+ }
1968
+ else { $kgvid_meta = false; }
1969
+
1970
+ $video_variables = array(
1971
+ 'id' => $div_suffix,
1972
+ 'attachment_id' => $id,
1973
+ 'player_type' => str_replace(' ', '', $options['embed_method']),
1974
+ 'width' => $query_atts['width'],
1975
+ 'height' => $query_atts['height'],
1976
+ 'fullwidth' => $query_atts['fullwidth'],
1977
+ 'countable' => $countable,
1978
+ 'autoplay' => $query_atts['autoplay'],
1979
+ 'set_volume' => $query_atts['volume'],
1980
+ 'mute' => $query_atts['mute'],
1981
+ 'meta' => $kgvid_meta,
1982
+ 'endofvideooverlay' => $query_atts['endofvideooverlay'],
1983
+ 'resize' => $query_atts['resize'],
1984
+ 'auto_res' => $query_atts['auto_res'],
1985
+ 'right_click' => $query_atts['right_click']
1986
+ );
1987
+
1988
+ if ( $options['embed_method'] == "Strobe Media Playback" && $flash_settings['flash_source_found'] ) {
1989
+
1990
+ $video_variables['swfurl'] = plugins_url('', __FILE__)."/flash/StrobeMediaPlayback.swf";
1991
+ $video_variables['expressinstallswfurl'] = plugins_url("", __FILE__)."/flash/expressInstall.swf";
1992
+ $video_variables['flashvars'] = $flash_settings['flashvars'];
1993
+ $video_variables['params'] = $flash_settings['params'];
1994
+
1995
+ } //if Strobe Media
1996
+
1997
+ $code .= '<div id="kgvid_'.$div_suffix.'_wrapper" class="kgvid_wrapper'.$aligncode.'">'."\n\t\t\t";
1998
+ $code .= '<div id="video_'.$div_suffix.'_div" class="fitvidsignore kgvid_videodiv" data-id="'.$div_suffix.'" data-kgvid_video_vars="'.esc_attr(json_encode($video_variables)).'" itemprop="video" itemscope itemtype="https://schema.org/VideoObject">';
1999
+ if ( $query_atts["poster"] != '' ) { $code .= '<meta itemprop="thumbnailUrl" content="'.esc_attr($query_atts["poster"]).'" />'; }
2000
+ if ( !empty($id) ) { $schema_embedURL = site_url('/')."?attachment_id=".$id."&amp;kgvid_video_embed[enable]=true"; }
2001
+ else { $schema_embedURL = $content; }
2002
+ $code .= '<meta itemprop="embedUrl" content="'.esc_attr($schema_embedURL).'" />';
2003
+ $code .= '<meta itemprop="contentUrl" content="'.$content.'" />';
2004
+
2005
+ if ( !empty($query_atts['title']) ) { $code .= '<meta itemprop="name" content="'.esc_attr($query_atts['title']).'" />'; }
2006
+
2007
+ if ( !empty($query_atts['description']) ) { $description = $query_atts['description']; }
2008
+ elseif ( !empty($query_atts['caption']) ) { $description = $query_atts['caption']; }
2009
+ elseif ( in_the_loop() && !is_attachment() ) {
2010
+ global $post;
2011
+ if ( !empty($post->post_excerpt) ) {
2012
+ $description = $post->post_excerpt;
2013
+ }
2014
+ else {
2015
+ $description = esc_attr(wp_trim_words(strip_tags(strip_shortcodes($post->post_content))));
2016
+ }
2017
+ }
2018
+ if ( empty($description) ) { $description = __('Video', 'video-embed-thumbnail-generator'); }
2019
+ $code .= '<meta itemprop="description" content="'.esc_attr($description).'" />';
2020
+
2021
+ if ( !empty($id) ) { $upload_date = get_the_date('c', $id); }
2022
+ elseif ( $post_ID != 1 ) { $upload_date = get_the_date('c', $post_ID); }
2023
+ else { $upload_date = current_time('c'); }
2024
+ $code .= '<meta itemprop="uploadDate" content="'.esc_attr($upload_date).'" />';
2025
+
2026
+ $track_keys = array('kind', 'srclang', 'src', 'label', 'default');
2027
+ if ( !isset($kgvid_postmeta) || ( is_array($kgvid_postmeta) && !is_array($kgvid_postmeta['track']) ) ) {
2028
+ $kgvid_postmeta['track'] = array();
2029
+ $kgvid_postmeta['track'][0] = array ( 'kind' => '', 'srclang' => '', 'src' => '', 'label' => '', 'default' => '');
2030
+ }
2031
+ foreach ( $track_keys as $key ) {
2032
+ if ( empty($kgvid_postmeta['track'][0][$key]) ) { $kgvid_postmeta['track'][0][$key] = $query_atts['track_'.$key]; }
2033
+ }
2034
+
2035
+ $track_code = "";
2036
+ if ( !empty($kgvid_postmeta['track'][0]['src']) ) {
2037
+ foreach ( $kgvid_postmeta['track'] as $track => $track_attribute ) {
2038
+ foreach ( $track_attribute as $attribute => $value ) {
2039
+ if ( empty($value) ) { $track_attribute[$attribute] = $query_atts['track_'.$attribute]; }
2040
+ }
2041
+ if ( $options['embed_method'] == "WordPress Default" && $track_attribute['kind'] == 'captions' ) { $track_attribute['kind'] = 'subtitles'; }
2042
+ $track_code .= "\t\t\t\t\t<track id='".$div_suffix."_text_".$track."' kind='".esc_attr($track_attribute['kind'])."' src='".esc_attr($track_attribute['src'])."' srclang='".esc_attr($track_attribute['srclang'])."' label='".esc_attr($track_attribute['label'])."' ".esc_attr($track_attribute['default'])." />\n";
2043
+ }
2044
+ }
2045
+
2046
+ if ( $options['embed_method'] == "WordPress Default" ) {
2047
+ $sources_hack = "";
2048
+ $attr = array();
2049
+ foreach ($video_formats as $format => $format_stats) {
2050
+ if ( $format != "original" && $encodevideo_info[$format]["url"] == $content ) { unset($sources['original']); }
2051
+ if ( $encodevideo_info[$format]["exists"] ) {
2052
+ if ( $format_stats['type'] != "h264" || !$mp4already ) {
2053
+ $shortcode_type = wp_check_filetype( $encodevideo_info[$format]["url"], wp_get_mime_types() );
2054
+ $attr[$shortcode_type['ext']] = $encodevideo_info[$format]["url"];
2055
+ if ( $format_stats['type'] == "h264" ) { //WordPress built-in shortcode doesn't support multiple videos of the same type but we'll hack it in later
2056
+ $mp4already = true;
2057
+ }
2058
+ }
2059
+ else { $sources_hack .= '<source type="'.$format_stats['mime'].'" src="'.esc_attr($encodevideo_info[$format]["url"]).'" />'; }
2060
+ }
2061
+ }
2062
+
2063
+ if ( $query_atts["poster"] != '' ) { $attr['poster'] = esc_attr($query_atts["poster"]); }
2064
+ if ( $query_atts["loop"] == 'true') { $attr['loop'] = "true"; }
2065
+ if ( $query_atts["autoplay"] == 'true') { $attr['autoplay'] = "true"; }
2066
+ $attr['preload'] = $options['preload'];
2067
+ $attr['width'] = $query_atts['width'];
2068
+ $attr['height'] = $query_atts['height'];
2069
+
2070
+ $content_width = $query_atts['width'];
2071
+ if ( function_exists('wp_video_shortcode') ) { $executed_shortcode = wp_video_shortcode($attr); }
2072
+ else { $executed_shortcode = 'WordPress video shortcode function does not exist.'; }
2073
+ $content_width = $content_width_save;
2074
+ if ( $sources_hack ) { //insert remaining mp4 sources manually
2075
+ $position = strpos($executed_shortcode, '<a href=');
2076
+ $executed_shortcode = substr_replace( $executed_shortcode, $sources_hack, $position, 0 );
2077
+ }
2078
+ if ( !empty($track_code) ) { //insert track code manually
2079
+ $position = strpos($executed_shortcode, '</video>');
2080
+ $executed_shortcode = substr_replace( $executed_shortcode, $track_code, $position, 0 );
2081
+ }
2082
+ $code .= $executed_shortcode;
2083
+ }
2084
+
2085
+ if ( $options['embed_method'] == "JW Player" ) {
2086
+
2087
+ if ( class_exists('JWP6_Shortcode') ) {
2088
+
2089
+ $x = 0;
2090
+ foreach ($video_formats as $format => $format_stats) {
2091
+ if ( $format != "original" && $encodevideo_info[$format]["url"] == $content ) { unset($sources['original']); }
2092
+ if ( $encodevideo_info[$format]["exists"] ) {
2093
+ if ( array_key_exists('height', $encodevideo_info[$format]) ) {
2094
+ $source_key = $encodevideo_info[$format]['height'];
2095
+ $format_stats['label'] = $encodevideo_info[$format]['height'].'p';
2096
+ }
2097
+ else { $source_key = $x; }
2098
+
2099
+ $sources[$source_key] = '{ file:\''.esc_attr($encodevideo_info[$format]["url"]).'\', label:\''.$format_stats['label'].'\'';
2100
+ if ( $format == "original" ) { $sources[$source_key] .= ', default:\'true\''; }
2101
+ $sources[$source_key] .= '}';
2102
+ $x++;
2103
+ }
2104
+ }
2105
+ krsort($sources);
2106
+
2107
+ $jw_tracks = array();
2108
+ if ( !empty($kgvid_postmeta['track'][0]['src']) ) {
2109
+ foreach ( $kgvid_postmeta['track'] as $track => $track_attribute ) {
2110
+ foreach ( $track_attribute as $attribute => $value ) {
2111
+ if ( empty($value) ) { $track_attribute[$attribute] = $query_atts['track_'.$attribute]; }
2112
+ }
2113
+ $default_text = '';
2114
+ if ( $track_attribute['default'] == 'default' ) { $default_text = ', \'default\': true'; }
2115
+ $jw_tracks[] = '{ file:\''.esc_attr($track_attribute['src']).'\', kind:\''.esc_attr($track_attribute['kind']).'\', label:\''.esc_attr($track_attribute['label']).'\''.$default_text.'}';
2116
+ }
2117
+ }
2118
+
2119
+ $jw_shortcode = "[jwplayer ";
2120
+ $jw_shortcode .= 'sources="'.implode(',', $sources).'" ';
2121
+ $jw_shortcode .= 'tracks="'.implode(',', $jw_tracks).'" ';
2122
+ if ( $query_atts["poster"] != '' ) { $jw_shortcode .= 'image="'.esc_attr($query_atts["poster"]).'" '; }
2123
+ if ( $query_atts["loop"] == 'true' ) { $jw_shortcode .= 'repeat="true" '; }
2124
+ if ( $query_atts["autoplay"] == 'true' ) { $jw_shortcode .= 'autostart="true" '; }
2125
+ if ( $query_atts["controlbar"] == 'none') { $jw_shortcode .= 'controls="false" '; }
2126
+ if ( $query_atts['title'] != "false" ) { $jw_shortcode .= ' title="'.$query_atts['title'].'" '; }
2127
+ if ( $options['jw_player_id'] != "") {
2128
+ $jw_player_config = get_option('jwp6_player_config_'.$options['jw_player_id']);
2129
+ if ( !empty($jw_player_config) ) { $jw_shortcode .= ' player="'.$options['jw_player_id'].'" '; }
2130
+ }
2131
+
2132
+ if ( !empty($query_atts['custom_atts']) && is_array($query_atts['custom_atts']) ) {
2133
+ foreach ( $query_atts['custom_atts'] as $jw_param => $jw_setting ) {
2134
+ $jw_shortcode .= ' '.$jw_param.'="'.$jw_setting.'" ';
2135
+ }
2136
+ }
2137
+
2138
+ $jw_shortcode = trim($jw_shortcode);
2139
+ $jw_shortcode .= ']';
2140
+
2141
+ //this is JW Player's hack for executing without registering a WP shortcode
2142
+ $tag_regex = '/(.?)\[(jwplayer)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?(.?)/s';
2143
+ $executed_shortcode = preg_replace_callback($tag_regex, array("JWP6_Shortcode", "tag_parser"), $jw_shortcode);
2144
+
2145
+ $code .= $executed_shortcode;
2146
+
2147
+ }// if class exists
2148
+ else { $options['embed_method'] = "Video.js"; }
2149
+
2150
+ }
2151
+
2152
+ if ( $options['embed_method'] == "Video.js" || $options['embed_method'] == "Strobe Media Playback" ) {
2153
+
2154
+ $enable_resolutions_plugin = false;
2155
+ $x = 20;
2156
+ $h264_resolutions = array();
2157
+
2158
+ foreach ($video_formats as $format => $format_stats) {
2159
+ if ( $format != "original" && $encodevideo_info[$format]["url"] == $content ) { unset($sources['original']); }
2160
+ if ( $encodevideo_info[$format]["exists"] ) {
2161
+
2162
+ if ( array_key_exists('height', $encodevideo_info[$format]) && $format_stats['type'] == 'h264' ) {
2163
+ $source_key = $encodevideo_info[$format]['height'];
2164
+ $format_stats['label'] = $encodevideo_info[$format]['height'].'p';
2165
+ }
2166
+ else { $source_key = $x; }
2167
+
2168
+ $sources[$source_key] = "\t\t\t\t\t".'<source src="'.esc_attr($encodevideo_info[$format]["url"]).'?id='.$kgvid_video_id.'" type="'.$format_stats["mime"].'"';
2169
+ if ( $format == 'vp9' ) { $sources[$source_key] .= ' codecs="vp9, vorbis"'; }
2170
+ if ( $format_stats['type'] == 'h264' ) {
2171
+ $sources[$source_key] .= ' data-res="'.$format_stats['label'].'"';
2172
+ if ( $mp4already ) { //there is more than one resolution available
2173
+ $enable_resolutions_plugin = true;
2174
+ }
2175
+ $mp4already = true;
2176
+ $h264_resolutions[] = $format_stats['label'];
2177
+ }
2178
+ else { $sources[$source_key] .= ' data-res="'.$format_stats['name'].'"'; }
2179
+ $sources[$source_key] .= '>'."\n";
2180
+ }
2181
+ $x--;
2182
+ }
2183
+ krsort($sources);
2184
+ natsort($h264_resolutions);
2185
+
2186
+ $code .= '<video id="video_'.$div_suffix.'" ';
2187
+ if ( $query_atts["loop"] == 'true') { $code .= 'loop '; }
2188
+ if ( $query_atts["autoplay"] == 'true') { $code .= 'autoplay '; }
2189
+ if ( $query_atts["controlbar"] != 'none') { $code .= 'controls '; }
2190
+ $code .= 'preload="'.$options['preload'].'" ';
2191
+ if ( $query_atts["poster"] != '' ) { $code .= 'poster="'.esc_attr($query_atts["poster"]).'" '; }
2192
+ $code .= 'width="'.$query_atts["width"].'" height="'.esc_attr($query_atts["height"]).'"';
2193
+ $locale = get_locale();
2194
+ if ( $options['js_skin'] == "" ) { $options['js_skin'] = "vjs-default-skin"; }
2195
+ if ( is_array($atts) && array_key_exists('skin', $atts) ) {
2196
+ $options['js_skin'] = $atts['skin']; //allows user to set skin for individual videos using the skin="" attribute
2197
+ }
2198
+ $code .= ' class="fitvidsignore '.esc_attr('video-js '.$options['js_skin']).'" data-setup=\'{ ';
2199
+ if ( $options['nativecontrolsfortouch'] == "on" ) { $code .= '"nativeControlsForTouch": true, '; }
2200
+ $code .= '"language": "'.substr($locale, 0, 2).'"';
2201
+ if ( $enable_resolutions_plugin ) { $code .= ', "plugins" : { "resolutionSelector" : { "force_types" : ["video/mp4"]';
2202
+ if ( $query_atts["auto_res"] == "highest" ) { $code .= ', "default_res": "'.end($h264_resolutions).'"'; }
2203
+ if ( $query_atts["auto_res"] == "lowest" ) { $code .= ', "default_res": "'.reset($h264_resolutions).'"'; }
2204
+ $code .= ' } }';
2205
+ }
2206
+ $code .= ' }\'';
2207
+ $code .= ">\n";
2208
+
2209
+ $code .= implode("", $sources); //add the <source> tags created earlier
2210
+ $code .= $track_code; //if there's a text track
2211
+ $code .= "\t\t\t\t</video>\n";
2212
+
2213
+ }
2214
+ $code .= "\t\t\t</div>\n";
2215
+ $show_views = false;
2216
+ if ( !empty($id) || !empty($query_atts['caption']) || $query_atts['downloadlink'] == "true" || $content == plugins_url('/images/sample-video-h264.mp4', __FILE__) ) { //generate content below the video
2217
+ if ( is_array($kgvid_postmeta) && array_key_exists('starts', $kgvid_postmeta) ) { $view_count = number_format(intval($kgvid_postmeta['starts'])); }
2218
+ else { $view_count = "0"; }
2219
+ if ( $content == plugins_url('/images/sample-video-h264.mp4', __FILE__) ) { $view_count = "XX"; }
2220
+ if ( $query_atts['view_count'] == "true" ) { $show_views = true; }
2221
+ if ( !empty($query_atts['caption']) || $show_views || $query_atts['downloadlink'] == "true" ) {
2222
+ $code .= "\t\t\t".'<div class="kgvid_below_video" id="video_'.$div_suffix.'_below">';
2223
+ if ( $show_views ) { $code .= '<div class="kgvid-viewcount" id="video_'.$div_suffix.'_viewcount">'.sprintf( _n( '%s view', '%s views', intval(str_replace(',', '', $view_count)) , 'video-embed-thumbnail-generator'), $view_count ).'</div>'; }
2224
+ if ( !empty($query_atts['caption']) || $query_atts['downloadlink'] == "true" ) {
2225
+ $code .= '<div class="kgvid-caption" id="video_'.$div_suffix.'_caption">'.$query_atts['caption'];
2226
+ if ( $query_atts['downloadlink'] == "true" ) {
2227
+ if ( !empty($query_atts['caption']) ) { $code .= '<br>'; }
2228
+ $forceable = false;
2229
+ if ( !empty($id) && $options['click_download'] == 'on' ) {
2230
+ $filepath = get_attached_file($id);
2231
+ if ( file_exists($filepath) ) {
2232
+ $forceable = true;
2233
+ $code .= '<a href="'.site_url('/').'?attachment_id='.$id.'&kgvid_video_embed[download]=true">'.__('Click on this link to download', 'video-embed-thumbnail-generator').'</a>';
2234
+ }
2235
+ }
2236
+ if ( !$forceable ) { $code .= '<a href="'.$content.'">'.__('Right-click or ctrl-click on this link to download', 'video-embed-thumbnail-generator').'</a>'; }
2237
+ }
2238
+ $code .= '</div>';
2239
+ }
2240
+ $code .= '</div>';
2241
+ }
2242
+ }
2243
+
2244
+ if ( $kgvid_meta == true ) { //generate content overlaid on video
2245
+ $code .= "\t\t\t<div style=\"display:none;\" id=\"video_".$div_suffix."_meta\" class=\"kgvid_video_meta kgvid_video_meta_hover\">\n";
2246
+ if ( $query_atts['embedcode'] != "false" ) {
2247
+ if ( $query_atts['embedcode'] == "true" ) { $iframeurl = site_url('/')."?attachment_id=".$id."&amp;kgvid_video_embed[enable]=true"; }
2248
+ else { $iframeurl = $query_atts['embedcode']; }
2249
+ $iframecode = "<iframe allowfullscreen src='".$iframeurl."' frameborder='0' scrolling='no' width='".esc_attr($query_atts['width'])."' height='".esc_attr($query_atts["height"])."'></iframe>";
2250
+ $code .= "\t\t\t\t<div id=\"video_".$div_suffix."_embed\" class=\"kgvid_share\"><span>"._x('Embed:', 'precedes code for embedding video', 'video-embed-thumbnail-generator')." </span><input type=\"text\" value=\"".esc_attr($iframecode)."\" onClick=\"this.select();\"></div>\n";
2251
+ }
2252
+ if ( $query_atts['title'] != "false" && $options['embed_method'] != "JW Player" ) {
2253
+ $code .= "\t\t\t\t<div id='video_".$div_suffix."_title' class='kgvid_title'>".$query_atts['title']."</div>\n";
2254
+ }
2255
+ $code .= "\t\t\t</div>\n";
2256
+ }
2257
+
2258
+ if ( !empty($query_atts["watermark"]) && $query_atts["watermark"] != "false" ) {
2259
+ $watermark_id = kgvid_url_to_id($query_atts["watermark"]);
2260
+ if ( $watermark_id ) { $query_atts["watermark"] = wp_get_attachment_url($watermark_id); }
2261
+ $code .= "<div style=\"display:none;\" id='video_".$div_suffix."_watermark' class='kgvid_watermark'>";
2262
+ if ( !empty($query_atts["watermark_url"]) && $query_atts["watermark_link_to"] != 'custom' ) { $query_atts["watermark_link_to"] = 'custom'; }
2263
+ if ( $query_atts['watermark_link_to'] != 'false' && $query_atts["watermark_url"] != 'false' ) {
2264
+ $watermark_link = true;
2265
+ switch ( $query_atts['watermark_link_to'] ) {
2266
+
2267
+ case 'home':
2268
+ $watermark_href = get_home_url();
2269
+ break;
2270
+
2271
+ case 'parent':
2272
+ if ( !empty($id) && is_object($attachment_info) && array_key_exists('post_parent', $attachment_info) && !empty($attachment_info->post_parent) ) {
2273
+ $watermark_href = get_permalink($attachment_info->post_parent);
2274
+ }
2275
+ else { $watermark_href = get_home_url(); }
2276
+ break;
2277
+
2278
+ case 'attachment':
2279
+ if ( !empty($id) ) {
2280
+ $watermark_href = get_permalink($id);
2281
+ }
2282
+ else { $watermark_href = get_home_url(); }
2283
+ break;
2284
+
2285
+ case 'download':
2286
+ if ( !empty($id) ) {
2287
+ $watermark_href = site_url('/').'?attachment_id='.$id.'&kgvid_video_embed[download]=true';
2288
+ }
2289
+ else { $watermark_href = $content; }
2290
+ break;
2291
+
2292
+ case 'custom':
2293
+ $watermark_href = $query_atts["watermark_url"];
2294
+ break;
2295
+
2296
+ }
2297
+ $code .= "<a target='_parent' href='".$watermark_href."'>";
2298
+ }
2299
+ else { $watermark_link = false; }
2300
+ $code .= "<img src='".esc_attr($query_atts["watermark"])."' alt='watermark'>";
2301
+ if ( $watermark_link ) { $code .= "</a>"; }
2302
+ $code .= "</div>";
2303
+ } //generate watermark
2304
+ $code .= "\t\t</div>"; //end kgvid_XXXX_wrapper div
2305
+
2306
+ $kgvid_video_id++;
2307
+
2308
+ } //end id_array loop
2309
+
2310
+ return $code;
2311
+
2312
+ }
2313
+
2314
function kgvid_shortcode_atts($atts) {
2315
2316
$options = kgvid_get_options();
2419
2420
function KGVID_shortcode($atts, $content = ''){
2421
2422
$code = "";
2423
if ( !is_feed() ) {
2424
2425
$options = kgvid_get_options();
2426
+
2427
kgvid_enqueue_shortcode_scripts();
2428
2429
if ( in_the_loop() ) { $post_ID = get_the_ID(); }
2433
2434
if ( $query_atts["gallery"] != "true" ) { //if this is not a pop-up gallery
2435
2436
+ $code = kgvid_single_video_code($query_atts, $atts, $content, $post_ID);
2437
2438
} //if not gallery
2439