Video Embed & Thumbnail Generator - Version 1.0.4

Version Description

  • November 4, 2011 =
  • More thorough check made for existing attachments before registering poster images with the Wordpress Media Library. Avoids registering duplicates or medium/small/thumb image sizes if they're used as poster image.
  • Added loop, autoplay, and controls options to HTML5 video elements.
  • When saving attachments, won't try to delete thumb_tmp directory if it doesn't exist.
Download this release

Release Info

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

Code changes from version 1.0.3 to 1.0.4

Files changed (2) hide show
  1. readme.txt +35 -13
  2. video-embed-thumbnail-generator.php +36 -20
readme.txt CHANGED
@@ -3,21 +3,21 @@ Contributors: kylegilman
3
  Tags: video, html5, shortcode, thumbnail, ffmpeg
4
  Requires at least: 3.0
5
  Tested up to: 3.3
6
- Stable tag: 1.0.3
7
 
8
  Generates thumbnails, HTML5-compliant videos, and embed codes for locally hosted videos. Requires FFMPEG for thumbnails and encodes.
9
 
10
  == Description ==
11
 
12
- A plugin for the Wordpress visual editor to make embedding videos, generating thumbnails, and encoding HTML5-compliant files a little bit easier.
13
 
14
  The plugin adds several fields to any video attachment in the Media Library:
15
 
16
- The embedded player will default to a Flash video player if you're using a Flash-compatible file (flv, f4v, mp4, mov, or m4v). Otherwise it will use an HTML5 video element. I highly recommend H.264 video and AAC audio in an MP4 container. If you're encoding with Apple's Compressor, the "Streaming" setting should be "Fast Start" (NOT Fast Start - Compressed Header). I've written up my recommended video encode settings in another post.
17
 
18
- The plugin uses FFMPEG to generate thumbnails and encode HTML5/mobile videos. By default the plugin looks for FFMPEG in /usr/local/bin but if FFMPEG is installed in a different place on your server, you can point it to the correct place in the plugin settings.
19
 
20
- If FFMPEG is installed on your server, you can generate thumbnails using either the "Generate" or "Randomize" buttons. The "Generate" button will always generate thumbnails from the same frames of your video, evenly spaced. If you don't like them you can randomize the results with the "Randomize" button. If you want to see the first frame of the video, check the "Force 1st Frame Thumbnail" button. If you want really fine control you can enter timecode in the "Thumbnail Timecode" field. Use mm:ss format. If you want even more control you can use decimals to approximate frames. For example, 23.5 will generate a thumbnail halfway between the 23rd and 24th seconds in the video. 02:23.25 would be one quarter of the way between the 143rd and 144th seconds. You can generate as many or as few as you need. The unused thumbnails will be deleted once you click "Insert into Post" or "Save Changes."
21
 
22
  In the plugin settings you can set the default maximum width based on the width of your particular template and those values will be filled in when you open the window. If you generate thumbnails, the video display dimensions will be automatically adjusted to match the size and aspect ratio of the video file. You can make further adjustments if you want.
23
 
@@ -25,20 +25,40 @@ The "Encode" button is still a bit experimental. If you have FFMPEG on your serv
25
 
26
  The plugin is currently favoring Flash instead of HTML5 because Flash is a better user experience in most cases. I'm particularly not a fan of some browsers' tendencies to auto-download HTML5 video elements. I may eventually include the option to favor HTML5. However, if you embed a non-Flash compatible file (like an ogv or webm file) then you will only get the HTML5 video element. If you want to make ogv, webm, or H.264 files available and can't use the FFMPEG encode button, you can upload your own files to the same directory as the original and the plugin will automatically find them. For example, if your main file is awesomevid.mp4, the plugin will look for awesomevid.webm and awesomevid.ogv as well. If you want to embed a high-res H.264 video but also make a mobile-compatible version available, add -ipod.m4v to the end of the filename (awesomevid-ipod.m4v) and it will be served up to most smartphones and tablets instead of the original.
27
 
28
- Android viewers who don't use Flash will see a play button superimposed on the thumbnail instead of the default still image.
29
 
30
  If you want to make it easier for people to save the video to their computers, you can choose to include a link by checking the "Generate Download Link Below Video" button.
31
 
32
- Sometimes for various reasons you might need to embed video files that are not saved in the Wordpress Media Library. Maybe your file is too large to upload through the media upload form, or maybe it's hosted on another server. Either way, you can use the new tab "Embed from URL" which works much like the old version of the plugin.
33
 
34
  Just enter the Video URL manually, and all other steps are the same as the Media Library options. If the video is in a directory that isn't writable, any encodes you make will go to an "html5encodes" subdirectory in the Wordpress uploads directory.
35
 
36
- Once you've filled in all your options, click "Insert Flash Media Player" and you'll get a shortcode in the visual editor like this
37
 
38
- `[FMP poster="http://www.kylegilman.net/wp-content/uploads/2011/10/Reel-11-10-10-web_thumb2.jpg" width="720" height="404"]http://www.kylegilman.net/wp-content/uploads/2011/10/Reel-11-10-10-web.mp4[/FMP]`
 
39
 
40
  Once you save the post, the thumbnail file will be registered in the Wordpress Media Library and added to the post's attachments. Thumbnails are saved in the current Wordpress uploads directory. HTML5 videos are not yet registered with the media library.
41
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
  I'm not really a software developer. I'm just a film editor with some time on his hands who wanted to post video for clients and wasn't happy with the current state of any available software. But I want to really make this thing work, so please help me out by posting your feedback in the comments. I'm developing the plugin on a VPS and I haven't tested it on any other FFMPEG-enabled servers yet, so I'm sure there are all kinds of things that only work because of my particular server setup.
43
 
44
  == Installation ==
@@ -46,19 +66,16 @@ I'm not really a software developer. I'm just a film editor with some time on hi
46
  1. Upload the unzipped folder `video-embed-thumbnail-generator` to the `/wp-content/plugins/` directory.
47
  1. Activate the plugin through the 'Plugins' menu in WordPress.
48
  1. Make sure you have all your MIME types configured correctly. Many servers don't have .mp4, .m4v, .ogv configured, and even more don't have .webm. There are a number of ways to do this. In your public_html directory you can edit your .htaccess file and add the following lines:
49
-
50
  `AddType video/ogg .ogv
51
  AddType video/mp4 .mp4
52
  AddType video/mp4 .m4v
53
  AddType video/webm .webm`
54
- 1. Follow instructions on the Description page.
55
 
56
  == Frequently Asked Questions ==
57
 
58
  = I'm on shared hosting and can't install software. Does this work without FFMPEG? =
59
 
60
- Some of it will work without FFMPEG. You can generate embed codes for your videos on any host because that part of the plugin is JavaScript running in your browser. Without FFMPEG you won't be able to generate thumbnails or generate HTML5 videos. There is no way around this. A program has to read the video files in order to generate the thumbnails, and FFMPEG is the best one I've found to do that.
61
-
62
 
63
  == Screenshots ==
64
 
@@ -68,6 +85,11 @@ Some of it will work without FFMPEG. You can generate embed codes for your video
68
 
69
  == Changelog ==
70
 
 
 
 
 
 
71
  = 1.0.3 - October 27, 2011 =
72
  * Revised thumbnail cleanup to make sure temp files aren't deleted when generating thumbnails for more than one video at a time.
73
 
3
  Tags: video, html5, shortcode, thumbnail, ffmpeg
4
  Requires at least: 3.0
5
  Tested up to: 3.3
6
+ Stable tag: 1.0.4
7
 
8
  Generates thumbnails, HTML5-compliant videos, and embed codes for locally hosted videos. Requires FFMPEG for thumbnails and encodes.
9
 
10
  == Description ==
11
 
12
+ = A plugin for the Wordpress visual editor to make embedding videos, generating thumbnails, and encoding HTML5-compliant files a little bit easier. =
13
 
14
  The plugin adds several fields to any video attachment in the Media Library:
15
 
16
+ The embedded player will default to a Flash video player if you're using a Flash-compatible file (flv, f4v, mp4, mov, or m4v). Otherwise it will use an HTML5 video element. I highly recommend H.264 video and AAC audio in an MP4 container. If you're encoding with Apple's Compressor, the "Streaming" setting should be "Fast Start" (NOT Fast Start - Compressed Header). I've written up my recommended video encode settings in <a href="http://www.kylegilman.net/2011/02/25/making-mp4-h-264-videos-in-apple-compressor/">a post on my website</a>.
17
 
18
+ The plugin uses FFMPEG to generate thumbnails and encode HTML5/mobile videos. By default the plugin looks for FFMPEG in `/usr/local/bin` but if FFMPEG is installed in a different place on your server, you can point it to the correct place in the plugin settings.
19
 
20
+ If FFMPEG is installed on your server, you can generate thumbnails using either the "Generate" or "Randomize" buttons. The "Generate" button will always generate thumbnails from the same frames of your video, evenly spaced. If you don't like them you can randomize the results with the "Randomize" button. If you want to see the first frame of the video, check the "Force 1st Frame Thumbnail" button. If you want really fine control you can enter timecode in the "Thumbnail Timecode" field. Use mm:ss format. If you want even more control you can use decimals to approximate frames. For example, `23.5` will generate a thumbnail halfway between the 23rd and 24th seconds in the video. `02:23.25` would be one quarter of the way between the 143rd and 144th seconds. You can generate as many or as few as you need. The unused thumbnails will be deleted once you click "Insert into Post" or "Save Changes."
21
 
22
  In the plugin settings you can set the default maximum width based on the width of your particular template and those values will be filled in when you open the window. If you generate thumbnails, the video display dimensions will be automatically adjusted to match the size and aspect ratio of the video file. You can make further adjustments if you want.
23
 
25
 
26
  The plugin is currently favoring Flash instead of HTML5 because Flash is a better user experience in most cases. I'm particularly not a fan of some browsers' tendencies to auto-download HTML5 video elements. I may eventually include the option to favor HTML5. However, if you embed a non-Flash compatible file (like an ogv or webm file) then you will only get the HTML5 video element. If you want to make ogv, webm, or H.264 files available and can't use the FFMPEG encode button, you can upload your own files to the same directory as the original and the plugin will automatically find them. For example, if your main file is awesomevid.mp4, the plugin will look for awesomevid.webm and awesomevid.ogv as well. If you want to embed a high-res H.264 video but also make a mobile-compatible version available, add -ipod.m4v to the end of the filename (awesomevid-ipod.m4v) and it will be served up to most smartphones and tablets instead of the original.
27
 
28
+ Android viewers who don't use Flash will see a play button superimposed on the thumbnail to make it a little clearer that it's an embedded video.
29
 
30
  If you want to make it easier for people to save the video to their computers, you can choose to include a link by checking the "Generate Download Link Below Video" button.
31
 
32
+ Sometimes for various reasons you might need to embed video files that are not saved in the Wordpress Media Library. Maybe your file is too large to upload through the media upload form, or maybe it's hosted on another server. Either way, you can use the new tab "Embed from URL" which works much like the 0.2 of this plugin.
33
 
34
  Just enter the Video URL manually, and all other steps are the same as the Media Library options. If the video is in a directory that isn't writable, any encodes you make will go to an "html5encodes" subdirectory in the Wordpress uploads directory.
35
 
36
+ = Once you've filled in all your options, click "Insert Flash Media Player" and you'll get a shortcode in the visual editor like this =
37
 
38
+ `[FMP poster="http://www.kylegilman.net/wp-content/uploads/2011/10/Reel-11-10-10-web_thumb2.jpg"
39
+ width="720" height="404"]http://www.kylegilman.net/wp-content/uploads/2011/10/Reel-11-10-10-web.mp4[/FMP]`
40
 
41
  Once you save the post, the thumbnail file will be registered in the Wordpress Media Library and added to the post's attachments. Thumbnails are saved in the current Wordpress uploads directory. HTML5 videos are not yet registered with the media library.
42
 
43
+ = If you want to further modify the way the Flash video player works, you can add the following options inside the [FMP] tag. These will override anything you’ve set in the plugin settings. =
44
+
45
+ * `poster="http://www.example.com/image.jpg"` sets the thumbnail
46
+ * `width="xxx"`
47
+ * `height="xxx"`
48
+ * `controlbar="docked/floating/none"` sets the controlbar position. HTML5 videos only respond to the "none" option.
49
+ * `loop="true/false"`
50
+ * `autoplay="true/false"`
51
+
52
+ = These options will only affect Flash video elements. They will have no effect on HTML5 videos. =
53
+
54
+ * `autohide="true/false"` specify whether to autohide the control bar after a few seconds.
55
+ * `playbutton="true/false"` turns the big play button overlay in the middle of the video on or off.
56
+ * `streamtype="live/recorded/DVR"` I honestly don’t know what this is for.
57
+ * `scalemode="letterbox/none/stretch/zoom"` If the video display size isn’t the same as the video file, this determines how the video will be scaled.
58
+ * `backgroundcolor="#rrggbb"` set the background color to whatever hex code you want.
59
+ * `configuration="http://www.example.com/config.xml"` Lets you specify all these flashvars in an XML file.
60
+ * `skin="http://www.example.com/skin.xml"` Completely change the look of the video player. <a href="http://www.longtailvideo.com/support/jw-player/jw-player-for-flash-v5/14/building-skins">Instructions here.</a>
61
+
62
  I'm not really a software developer. I'm just a film editor with some time on his hands who wanted to post video for clients and wasn't happy with the current state of any available software. But I want to really make this thing work, so please help me out by posting your feedback in the comments. I'm developing the plugin on a VPS and I haven't tested it on any other FFMPEG-enabled servers yet, so I'm sure there are all kinds of things that only work because of my particular server setup.
63
 
64
  == Installation ==
66
  1. Upload the unzipped folder `video-embed-thumbnail-generator` to the `/wp-content/plugins/` directory.
67
  1. Activate the plugin through the 'Plugins' menu in WordPress.
68
  1. Make sure you have all your MIME types configured correctly. Many servers don't have .mp4, .m4v, .ogv configured, and even more don't have .webm. There are a number of ways to do this. In your public_html directory you can edit your .htaccess file and add the following lines:
 
69
  `AddType video/ogg .ogv
70
  AddType video/mp4 .mp4
71
  AddType video/mp4 .m4v
72
  AddType video/webm .webm`
 
73
 
74
  == Frequently Asked Questions ==
75
 
76
  = I'm on shared hosting and can't install software. Does this work without FFMPEG? =
77
 
78
+ Some of it will work without FFMPEG. You can generate embed codes for your videos on any host because that part of the plugin is JavaScript running in your browser. But without FFMPEG you won't be able to generate thumbnails or generate HTML5 videos. There is no way around this. A program has to read the video files in order to generate the thumbnails, and FFMPEG is the best one I've found to do that.
 
79
 
80
  == Screenshots ==
81
 
85
 
86
  == Changelog ==
87
 
88
+ = 1.0.4 - November 4, 2011 =
89
+ * More thorough check made for existing attachments before registering poster images with the Wordpress Media Library. Avoids registering duplicates or medium/small/thumb image sizes if they're used as poster image.
90
+ * Added loop, autoplay, and controls options to HTML5 video elements.
91
+ * When saving attachments, won't try to delete thumb_tmp directory if it doesn't exist.
92
+
93
  = 1.0.3 - October 27, 2011 =
94
  * Revised thumbnail cleanup to make sure temp files aren't deleted when generating thumbnails for more than one video at a time.
95
 
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: Generate video thumbnails, HTML5-compliant videos, and video embed shortcodes. Some functions require FFMPEG.
6
- Version: 1.0.3
7
  Author: Kyle Gilman
8
  Author URI: http://www.kylegilman.net/
9
 
@@ -238,15 +238,18 @@ function FMP_shortcode($atts, $content = ''){
238
 
239
  $code = "<div id=\"flashcontent".$div_suffix."\">";
240
  $code .= "<video ";
 
 
 
241
  if ($isAndroid) { $code .= "onclick='this.play();' "; }
242
- $code .= "controls='controls'";
243
  if($query_atts["poster"] != '' && !$isAndroid) {
244
- $code .= " poster='".$query_atts["poster"]."' ";
245
  }
246
  if($query_atts["poster"] != '' && $isAndroid) {
247
- $code .= " poster='".plugins_url('', __FILE__)."/images/androidthumb.php?src=".$query_atts["poster"]."' ";
248
  }
249
- $code .= " width='".$query_atts["width"]."' height='".$query_atts["height"]."'";
250
  $code .= ">\n";
251
 
252
  if ( in_array($moviefiletype, $h264compatible) ) {
@@ -743,23 +746,33 @@ function FMPOptionsPage() {
743
 
744
  }
745
 
746
- function kg_addPostSave($post_id) {
747
  global $flag;
748
- if ($flag == 1) { //if draft already saved
749
  $current_post = get_post($post_id);
750
- preg_match_all('/poster="([^"\r\n]*)"/', $current_post->post_content, $matches);
751
  $uploads = wp_upload_dir();
752
 
753
- $post_children =& get_children('post_parent='.$post_id);
754
- $existing_attachment = array();
755
- $i=0;
756
- foreach ($post_children as $child) {
757
- $existing_attachment[$i] = $child->guid;
758
- $i++;
759
- }
 
 
 
 
 
 
 
 
 
 
 
760
 
761
  foreach ($matches[1] as $url) {
762
- if(!in_array($url, $existing_attachment)) {
763
  $filename_baseurl = substr($url, 0, strlen($uploads['baseurl']));
764
  if ( $filename_baseurl == $uploads['baseurl'] ) {
765
  $filename = str_replace($filename_baseurl, $uploads['basedir'], $url);
@@ -872,9 +885,12 @@ add_action('save_post', 'kg_addPostSave');
872
  $thumbnail_html = '<div style="border-style:solid; border-color:#ccc; border-width:3px; width:200px; text-align:center; margin:10px;"><img width="200" src="'.$thumbnail_url.'"></div>';
873
  }
874
 
 
 
 
875
  $form_fields["generator"]["label"] = __("Thumbnails");
876
  $form_fields["generator"]["input"] = "html";
877
- $form_fields["generator"]["html"] = '<div id="attachments_'. $post->ID .'_thumbnailplaceholder">'. $thumbnail_html .'</div><input id="attachments_'. $post->ID .'_numberofthumbs" type="text" value="4" maxlength="1" size="4" style="width:25px;" title="Number of Thumbnails" onchange="document.getElementById(\'attachments['.$post->ID.'][thumbtime]\').value =\'\';"><input type="button" id="attachments['. $post->ID .'][thumbgenerate]" class="button-secondary" value="Generate" name="thumbgenerate" onclick="kg_generate_thumb('. $post->ID .', \'generate\');"/><input type="button" id="thumbrandomize" class="button-secondary" value="Randomize" name="thumbrandomize" onclick="kg_generate_thumb('. $post->ID .', \'random\');" /><input type="button" id="attachments['. $post->ID .'][deletebutton]" class="button-secondary" value="Delete" name="deletebutton" onclick="kg_generate_thumb('. $post->ID .', \'delete\');"/> <input type="checkbox" id="attachments_'. $post->ID .'_firstframe"><label for="attachments_'. $post->ID .'_firstframe">Force 1st Frame Thumbnail</label>';
878
 
879
  $form_fields["thumbtime"]["label"] = __("Thumbnail Timecode");
880
  $form_fields["thumbtime"]["value"] = get_post_meta($post->ID, "_kgflashmediaplayer-thumbtime", true);
@@ -933,7 +949,7 @@ add_action('save_post', 'kg_addPostSave');
933
  unlink($thumbfilename);
934
  }
935
  }
936
- rmdir($uploads['path'].'/thumb_tmp');
937
  }
938
  update_post_meta($post['ID'], '_kgflashmediaplayer-poster', $attachment['kgflashmediaplayer-poster']);
939
  }
@@ -993,7 +1009,7 @@ $kgIM = new kgInsertMedia();
993
  //add_filter('video_send_to_editor_url', 'kg_filter_video_url', 20, 3);
994
 
995
  //function kg_filter_video_url($html, $href, $title) { //when inserting via URL only
996
- // $html = '[FMP]'.$href.'"[/FMP]';
997
  // return $html;
998
  //}
999
 
@@ -1024,7 +1040,7 @@ media_upload_header();
1024
  </tr>
1025
  <tr>
1026
  <th valign="top" scope="row" class="label"><span class="alignleft"><label for="numberofthumbs">Thumbnails</label></span></th>
1027
- <td class="field"><div id="attachments_singleurl_thumbnailplaceholder"></div><input id="attachments_singleurl_numberofthumbs" type="text" value="4" maxlength="2" size="4" style="width:25px;" title="Number of Thumbnails" onchange="document.getElementById('attachments[singleurl][thumbtime]').value='';"><input type="button" id="attachments[singleurl][thumbgenerate]" class="button-secondary" value="Generate" name="thumbgenerate" onclick="kg_generate_thumb('singleurl', 'generate');"/><input type="button" id="thumbrandomize" class="button-secondary" value="Randomize" name="thumbrandomize" onclick="kg_generate_thumb('singleurl', 'random');" /><input type="button" id="attachments['singleurl'][deletebutton]" class="button-secondary" value="Delete" name="deletebutton" onclick="kg_generate_thumb('singleurl', 'delete');"/> <input type="checkbox" id="attachments_singleurl_firstframe"><label for="attachments_1_firstframe">Force 1st Frame Thumbnail</label></td>
1028
  </tr>
1029
  <tr>
1030
  <th valign="top" scope="row" class="label"><span class="alignleft"><label for="attachments[singleurl][thumbtime]">Thumbnail Timecode</span></label><br class="clear" /></th>
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: Generate video thumbnails, HTML5-compliant videos, and video embed shortcodes. Some functions require FFMPEG.
6
+ Version: 1.0.4
7
  Author: Kyle Gilman
8
  Author URI: http://www.kylegilman.net/
9
 
238
 
239
  $code = "<div id=\"flashcontent".$div_suffix."\">";
240
  $code .= "<video ";
241
+ if ($query_atts["loop"] == 'true') { $code .= "loop='loop' " ;}
242
+ if ($query_atts["autoplay"] == 'true') { $code .= "autoplay='autoplay' " ;}
243
+ if ($query_atts["controls"] != 'none') { $code .= "controls='controls' " ;}
244
  if ($isAndroid) { $code .= "onclick='this.play();' "; }
245
+ $code .= "preload='metadata' ";
246
  if($query_atts["poster"] != '' && !$isAndroid) {
247
+ $code .= "poster='".$query_atts["poster"]."' ";
248
  }
249
  if($query_atts["poster"] != '' && $isAndroid) {
250
+ $code .= "poster='".plugins_url('', __FILE__)."/images/androidthumb.php?src=".$query_atts["poster"]."' ";
251
  }
252
+ $code .= "width='".$query_atts["width"]."' height='".$query_atts["height"]."'";
253
  $code .= ">\n";
254
 
255
  if ( in_array($moviefiletype, $h264compatible) ) {
746
 
747
  }
748
 
749
+ function kg_addPostSave($post_id) { //saves the poster image as an attachment
750
  global $flag;
751
+ if ($flag == 1) { //if draft already saved. Helps prevent duplicates.
752
  $current_post = get_post($post_id);
 
753
  $uploads = wp_upload_dir();
754
 
755
+ preg_match_all('/poster="([^"\r\n]*)"/', $current_post->post_content, $matches);
756
+
757
+ if (!empty($matches[1])) {
758
+ $args = array( 'post_type' => 'attachment', 'numberposts' => -1, 'post_status' => null, 'post_parent' => null, 'post_mime_type' => 'image' );
759
+ $post_children = get_posts( $args );
760
+ $existing_attachment = array();
761
+ $i=0;
762
+ foreach ($post_children as $child) {
763
+ $existing_attachment[$i] = $child->guid;
764
+ $i++;
765
+ $kg_image_sizes = get_intermediate_image_sizes();
766
+ foreach ($kg_image_sizes as $size_name) {
767
+ $current_image_size_src = wp_get_attachment_image_src($child->ID, $size_name);
768
+ $existing_attachment[$i] = $current_image_size_src[0];
769
+ $i++;
770
+ }//each image size URL
771
+ }//each attachment
772
+ }//if there are any poster urls set in the post
773
 
774
  foreach ($matches[1] as $url) {
775
+ if(!in_array($url, $existing_attachment) && !is_local_attachment($url) ) {
776
  $filename_baseurl = substr($url, 0, strlen($uploads['baseurl']));
777
  if ( $filename_baseurl == $uploads['baseurl'] ) {
778
  $filename = str_replace($filename_baseurl, $uploads['basedir'], $url);
885
  $thumbnail_html = '<div style="border-style:solid; border-color:#ccc; border-width:3px; width:200px; text-align:center; margin:10px;"><img width="200" src="'.$thumbnail_url.'"></div>';
886
  }
887
 
888
+ if (get_post_meta($post->ID, "_kgflashmediaplayer-thumbtime", true) != "") { $numberofthumbs_value = "1"; }
889
+ else { $numberofthumbs_value = "4"; }
890
+
891
  $form_fields["generator"]["label"] = __("Thumbnails");
892
  $form_fields["generator"]["input"] = "html";
893
+ $form_fields["generator"]["html"] = '<div id="attachments_'. $post->ID .'_thumbnailplaceholder">'. $thumbnail_html .'</div><input id="attachments_'. $post->ID .'_numberofthumbs" type="text" value="'.$numberofthumbs_value.'" maxlength="1" size="4" style="width:25px;" title="Number of Thumbnails" onchange="document.getElementById(\'attachments['.$post->ID.'][thumbtime]\').value =\'\';"><input type="button" id="attachments['. $post->ID .'][thumbgenerate]" class="button-secondary" value="Generate" name="thumbgenerate" onclick="kg_generate_thumb('. $post->ID .', \'generate\');"/><input type="button" id="thumbrandomize" class="button-secondary" value="Randomize" name="thumbrandomize" onclick="kg_generate_thumb('. $post->ID .', \'random\');" /> <input type="checkbox" id="attachments_'. $post->ID .'_firstframe"><label for="attachments_'. $post->ID .'_firstframe">Force 1st Frame Thumbnail</label>';
894
 
895
  $form_fields["thumbtime"]["label"] = __("Thumbnail Timecode");
896
  $form_fields["thumbtime"]["value"] = get_post_meta($post->ID, "_kgflashmediaplayer-thumbtime", true);
949
  unlink($thumbfilename);
950
  }
951
  }
952
+ if ( is_dir($uploads['path'].'/thumb_tmp') ) { rmdir($uploads['path'].'/thumb_tmp'); }
953
  }
954
  update_post_meta($post['ID'], '_kgflashmediaplayer-poster', $attachment['kgflashmediaplayer-poster']);
955
  }
1009
  //add_filter('video_send_to_editor_url', 'kg_filter_video_url', 20, 3);
1010
 
1011
  //function kg_filter_video_url($html, $href, $title) { //when inserting via URL only
1012
+ $html = '[FMP]'.$href.'"[/FMP]';
1013
  // return $html;
1014
  //}
1015
 
1040
  </tr>
1041
  <tr>
1042
  <th valign="top" scope="row" class="label"><span class="alignleft"><label for="numberofthumbs">Thumbnails</label></span></th>
1043
+ <td class="field"><div id="attachments_singleurl_thumbnailplaceholder"></div><input id="attachments_singleurl_numberofthumbs" type="text" value="4" maxlength="2" size="4" style="width:25px;" title="Number of Thumbnails" onchange="document.getElementById('attachments[singleurl][thumbtime]').value='';"><input type="button" id="attachments[singleurl][thumbgenerate]" class="button-secondary" value="Generate" name="thumbgenerate" onclick="kg_generate_thumb('singleurl', 'generate');"/><input type="button" id="thumbrandomize" class="button-secondary" value="Randomize" name="thumbrandomize" onclick="kg_generate_thumb('singleurl', 'random');" /> <input type="checkbox" id="attachments_singleurl_firstframe"><label for="attachments_singleurl_firstframe">Force 1st Frame Thumbnail</label></td>
1044
  </tr>
1045
  <tr>
1046
  <th valign="top" scope="row" class="label"><span class="alignleft"><label for="attachments[singleurl][thumbtime]">Thumbnail Timecode</span></label><br class="clear" /></th>