Version Description
- October 27, 2011 =
- Revised thumbnail cleanup to make sure temp files aren't deleted when generating thumbnails for more than one video at a time.
Download this release
Release Info
Developer | kylegilman |
Plugin | Video Embed & Thumbnail Generator |
Version | 1.0.3 |
Comparing to | |
See all releases |
Code changes from version 1.0.2 to 1.0.3
- kg_callffmpeg.php +6 -3
- kg_video_plugin.js +2 -0
- readme.txt +5 -8
- video-embed-thumbnail-generator.php +42 -21
kg_callffmpeg.php
CHANGED
@@ -299,11 +299,14 @@ if ($action == submit) {
|
|
299 |
$tmp_posterpath = $uploads["path"].'/thumb_tmp/'.$posterfile;
|
300 |
$final_posterpath = $uploads["path"].'/'.$posterfile;
|
301 |
if ( is_file($tmp_posterpath) ) { copy($tmp_posterpath, $final_posterpath); }
|
302 |
-
rrmdir($uploads['path'].'/thumb_tmp');
|
303 |
|
304 |
-
|
305 |
-
|
|
|
|
|
306 |
|
|
|
|
|
307 |
|
308 |
}//if submit
|
309 |
|
299 |
$tmp_posterpath = $uploads["path"].'/thumb_tmp/'.$posterfile;
|
300 |
$final_posterpath = $uploads["path"].'/'.$posterfile;
|
301 |
if ( is_file($tmp_posterpath) ) { copy($tmp_posterpath, $final_posterpath); }
|
|
|
302 |
|
303 |
+
$thumb_base = substr($tmp_posterpath, 0, -5);
|
304 |
+
foreach (glob($thumb_base."?.jpg") as $thumbfilename) {
|
305 |
+
unlink($thumbfilename);
|
306 |
+
}
|
307 |
|
308 |
+
//$arr = array ( "posterfile"=>$posterfile, "tmp_posterpath"=>$tmp_posterpath, "final_posterpath"=>$final_posterpath );
|
309 |
+
//echo json_encode($arr);
|
310 |
|
311 |
}//if submit
|
312 |
|
kg_video_plugin.js
CHANGED
@@ -84,6 +84,8 @@ function kg_generate_thumb(postID, buttonPushed) {
|
|
84 |
|
85 |
}, "json");
|
86 |
|
|
|
|
|
87 |
}
|
88 |
|
89 |
function kg_insert_shortcode() {
|
84 |
|
85 |
}, "json");
|
86 |
|
87 |
+
jQuery.post( ajaxurl , { action:"kg_schedule_cleanup_generated_files" } );
|
88 |
+
|
89 |
}
|
90 |
|
91 |
function kg_insert_shortcode() {
|
readme.txt
CHANGED
@@ -2,17 +2,13 @@
|
|
2 |
Contributors: kylegilman
|
3 |
Tags: video, html5, shortcode, thumbnail, ffmpeg
|
4 |
Requires at least: 3.0
|
5 |
-
Tested up to: 3.
|
6 |
-
Stable tag: 1.0.
|
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 |
-
This is a big re-write. You no longer have to manually choose the video URL. The visual-editor plugin with my icon is gone. Just click "Insert Video" to get things started.
|
13 |
-
|
14 |
-
I would appreciate any feedback you have.
|
15 |
-
|
16 |
A plugin for the Wordpress visual editor to make embedding videos, generating thumbnails, and encoding HTML5-compliant files a little bit easier.
|
17 |
|
18 |
The plugin adds several fields to any video attachment in the Media Library:
|
@@ -55,8 +51,6 @@ I'm not really a software developer. I'm just a film editor with some time on hi
|
|
55 |
AddType video/mp4 .mp4
|
56 |
AddType video/mp4 .m4v
|
57 |
AddType video/webm .webm`
|
58 |
-
|
59 |
-
Or use your web host's configuration panel (cpanel, etc) to add a custom MIME type.
|
60 |
1. Follow instructions on the Description page.
|
61 |
|
62 |
== Frequently Asked Questions ==
|
@@ -74,6 +68,9 @@ Some of it will work without FFMPEG. You can generate embed codes for your video
|
|
74 |
|
75 |
== Changelog ==
|
76 |
|
|
|
|
|
|
|
77 |
= 1.0.2 - October 21, 2011 =
|
78 |
* Fixed a shocking number of unenclosed stings in get_options() calls. Bad programming. Didn't affect functionality, but will stop generating errors.
|
79 |
* Removed clumsy check for FFMPEG running. Was preventing encoding if ANY user on the server was running FFMPEG. Be wary of overusing your system resources though.
|
2 |
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:
|
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 ==
|
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 |
+
|
74 |
= 1.0.2 - October 21, 2011 =
|
75 |
* Fixed a shocking number of unenclosed stings in get_options() calls. Bad programming. Didn't affect functionality, but will stop generating errors.
|
76 |
* Removed clumsy check for FFMPEG running. Was preventing encoding if ANY user on the server was running FFMPEG. Be wary of overusing your system resources though.
|
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.
|
7 |
Author: Kyle Gilman
|
8 |
Author URI: http://www.kylegilman.net/
|
9 |
|
@@ -277,14 +277,14 @@ function FMP_shortcode($atts, $content = ''){
|
|
277 |
}
|
278 |
|
279 |
return $code;
|
280 |
-
|
281 |
-
|
282 |
|
283 |
-
|
284 |
add_options_page('Video Embed & Thumbnail Generator', 'Video Embed & Thumbnail Generator', 8, basename(__FILE__), 'FMPOptionsPage');
|
285 |
}
|
286 |
|
287 |
-
|
288 |
|
289 |
if (isset($_POST['wp_FMP_reset'])) {
|
290 |
update_option(wp_FMP_swfobject, wp_FMP_swfobject_default);
|
@@ -785,7 +785,7 @@ function kg_addPostSave($post_id) {
|
|
785 |
}//if post not already saved
|
786 |
$flag = 1;
|
787 |
}
|
788 |
-
|
789 |
|
790 |
|
791 |
/**
|
@@ -867,13 +867,14 @@ function kg_addPostSave($post_id) {
|
|
867 |
}
|
868 |
else { if ( !url_exists($thumbnail_url) ) { $thumbnail_url = ""; } }
|
869 |
|
|
|
870 |
if ($thumbnail_url != "" ) {
|
871 |
$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>';
|
872 |
}
|
873 |
|
874 |
$form_fields["generator"]["label"] = __("Thumbnails");
|
875 |
$form_fields["generator"]["input"] = "html";
|
876 |
-
$form_fields["generator"]["html"] = '<div id="attachments_'. $post->ID .'_thumbnailplaceholder">'. $thumbnail_html .'</div><input id="attachments_'. $post->ID .'_numberofthumbs" type="text" value="4" maxlength="
|
877 |
|
878 |
$form_fields["thumbtime"]["label"] = __("Thumbnail Timecode");
|
879 |
$form_fields["thumbtime"]["value"] = get_post_meta($post->ID, "_kgflashmediaplayer-thumbtime", true);
|
@@ -920,13 +921,19 @@ function kg_addPostSave($post_id) {
|
|
920 |
// $attachment part of the form $_POST ($_POST[attachments][postID])
|
921 |
// $post attachments wp post array - will be saved after returned
|
922 |
// $post['post_type'] == 'attachment'
|
923 |
-
if( isset($attachment['kgflashmediaplayer-poster']) ) {
|
924 |
-
|
925 |
-
|
926 |
-
|
927 |
-
|
928 |
-
if ( is_file($tmp_posterpath) ) {
|
929 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
930 |
}
|
931 |
update_post_meta($post['ID'], '_kgflashmediaplayer-poster', $attachment['kgflashmediaplayer-poster']);
|
932 |
}
|
@@ -1045,7 +1052,7 @@ media_upload_header();
|
|
1045 |
<tr class="submit">
|
1046 |
<td></td>
|
1047 |
<td>
|
1048 |
-
<input type="submit" onclick="kg_insert_shortcode();" name="insertonlybutton" id="insertonlybutton" class="button" value="Insert into Post" />
|
1049 |
</td>
|
1050 |
</tr>
|
1051 |
</tbody></table>
|
@@ -1071,22 +1078,36 @@ $maxwidth = get_option('wp_FMP_width');
|
|
1071 |
</form>
|
1072 |
|
1073 |
<?php
|
1074 |
-
}
|
|
|
1075 |
function kg_embedurl_handle() {
|
1076 |
return wp_iframe( 'media_embedurl_process');
|
1077 |
}
|
1078 |
add_action('media_upload_embedurl', 'kg_embedurl_handle');
|
1079 |
|
1080 |
|
1081 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1082 |
wp_enqueue_script( 'video_embed_thumbnail_generator_script', plugins_url('/kg_video_plugin.js', __FILE__) );
|
1083 |
}
|
|
|
1084 |
|
1085 |
add_action('wp_head', 'addSWFObject');
|
1086 |
add_action('admin_menu', 'addFMPOptionsPage');
|
1087 |
-
add_action('save_post', 'kg_addPostSave');
|
1088 |
-
add_action('admin_enqueue_scripts', 'enqueue_kg_script');
|
1089 |
-
|
1090 |
-
add_shortcode('FMP', 'FMP_shortcode');
|
1091 |
|
1092 |
?>
|
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 |
|
277 |
}
|
278 |
|
279 |
return $code;
|
280 |
+
}
|
281 |
+
add_shortcode('FMP', 'FMP_shortcode');
|
282 |
|
283 |
+
function addFMPOptionsPage() {
|
284 |
add_options_page('Video Embed & Thumbnail Generator', 'Video Embed & Thumbnail Generator', 8, basename(__FILE__), 'FMPOptionsPage');
|
285 |
}
|
286 |
|
287 |
+
function FMPOptionsPage() {
|
288 |
|
289 |
if (isset($_POST['wp_FMP_reset'])) {
|
290 |
update_option(wp_FMP_swfobject, wp_FMP_swfobject_default);
|
785 |
}//if post not already saved
|
786 |
$flag = 1;
|
787 |
}
|
788 |
+
add_action('save_post', 'kg_addPostSave');
|
789 |
|
790 |
|
791 |
/**
|
867 |
}
|
868 |
else { if ( !url_exists($thumbnail_url) ) { $thumbnail_url = ""; } }
|
869 |
|
870 |
+
$thumbnail_html = "";
|
871 |
if ($thumbnail_url != "" ) {
|
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);
|
921 |
// $attachment part of the form $_POST ($_POST[attachments][postID])
|
922 |
// $post attachments wp post array - will be saved after returned
|
923 |
// $post['post_type'] == 'attachment'
|
924 |
+
if( isset($attachment['kgflashmediaplayer-poster']) ) {
|
925 |
+
$uploads = wp_upload_dir();
|
926 |
+
$posterfile = pathinfo($attachment['kgflashmediaplayer-poster'], PATHINFO_BASENAME);
|
927 |
+
$tmp_posterpath = $uploads['path'].'/thumb_tmp/'.$posterfile;
|
928 |
+
if ( !is_file($uploads['path'].'/'.$posterfile) ) {
|
929 |
+
if ( is_file($tmp_posterpath) ) {
|
930 |
+
copy($tmp_posterpath, $uploads['path'].'/'.$posterfile);
|
931 |
+
$thumb_base = substr($tmp_posterpath, 0, -5);
|
932 |
+
foreach (glob($thumb_base."?.jpg") as $thumbfilename) {
|
933 |
+
unlink($thumbfilename);
|
934 |
+
}
|
935 |
+
}
|
936 |
+
rmdir($uploads['path'].'/thumb_tmp');
|
937 |
}
|
938 |
update_post_meta($post['ID'], '_kgflashmediaplayer-poster', $attachment['kgflashmediaplayer-poster']);
|
939 |
}
|
1052 |
<tr class="submit">
|
1053 |
<td></td>
|
1054 |
<td>
|
1055 |
+
<input type="submit" onclick="kg_generate_thumb('singleurl', 'submit'); kg_insert_shortcode();" name="insertonlybutton" id="insertonlybutton" class="button" value="Insert into Post" />
|
1056 |
</td>
|
1057 |
</tr>
|
1058 |
</tbody></table>
|
1078 |
</form>
|
1079 |
|
1080 |
<?php
|
1081 |
+
} //end media_embedurl_process
|
1082 |
+
|
1083 |
function kg_embedurl_handle() {
|
1084 |
return wp_iframe( 'media_embedurl_process');
|
1085 |
}
|
1086 |
add_action('media_upload_embedurl', 'kg_embedurl_handle');
|
1087 |
|
1088 |
|
1089 |
+
|
1090 |
+
|
1091 |
+
function kg_cleanup_generated_thumbnails_handler($posterurl) {
|
1092 |
+
$uploads = wp_upload_dir();
|
1093 |
+
rrmdir($uploads['path'].'/thumb_tmp'); //remove the whole tmp file directory
|
1094 |
+
}
|
1095 |
+
add_action('kg_cleanup_generated_thumbnails','kg_cleanup_generated_thumbnails_handler');
|
1096 |
+
|
1097 |
+
function kg_schedule_cleanup_generated_files() { //schedules deleting all tmp thumbnails if no thumbnails are generated in an hour
|
1098 |
+
$timestamp = wp_next_scheduled( 'kg_cleanup_generated_thumbnails' );
|
1099 |
+
wp_unschedule_event($timestamp, 'kg_cleanup_generated_thumbnails' );
|
1100 |
+
wp_schedule_single_event(time()+3600, 'kg_cleanup_generated_thumbnails');
|
1101 |
+
die(); // this is required to return a proper result
|
1102 |
+
}
|
1103 |
+
add_action('wp_ajax_kg_schedule_cleanup_generated_files', 'kg_schedule_cleanup_generated_files');
|
1104 |
+
|
1105 |
+
function enqueue_kg_script() { //loads plugin-related javascripts
|
1106 |
wp_enqueue_script( 'video_embed_thumbnail_generator_script', plugins_url('/kg_video_plugin.js', __FILE__) );
|
1107 |
}
|
1108 |
+
add_action('admin_enqueue_scripts', 'enqueue_kg_script');
|
1109 |
|
1110 |
add_action('wp_head', 'addSWFObject');
|
1111 |
add_action('admin_menu', 'addFMPOptionsPage');
|
|
|
|
|
|
|
|
|
1112 |
|
1113 |
?>
|