Video Thumbnails - Version 1.5

Version Description

  • Video thumbnails are now only saved when a post's status changes to published.
  • Removed URL field from the Video Thumbnail meta box on the Edit Post Page
  • Added a "Reset Video Thumbnail" button to the meta box
  • Accidental duplicate images should no longer be problem
Download this release

Release Info

Developer sutherlandboswell
Plugin Icon 128x128 Video Thumbnails
Version 1.5
Comparing to
See all releases

Code changes from version 1.1.1 to 1.5

Files changed (3) hide show
  1. readme.txt +14 -9
  2. screenshot-1.gif +0 -0
  3. video-thumbnails.php +69 -20
readme.txt CHANGED
@@ -3,14 +3,14 @@ Contributors: sutherlandboswell
3
  Donate link: http://amzn.com/w/1L25YG6FO8AZ1
4
  Tags: Video, YouTube, Vimeo, Blip.tv, Justin.tv, Thumbnails
5
  Requires at least: 3.0
6
- Tested up to: 3.0.4
7
- Stable tag: 1.1.1
8
 
9
- Video Thumbnails is a simple plugin that makes it easy to automatically display video thumbnails in your template.
10
 
11
  == Description ==
12
 
13
- Video Thumbnails makes it easy to automatically display video thumbnails in your template. This plugin will pull the thumbnail for you, save it to your media library, and set it as the featured image. You can choose to turn off featured images
14
 
15
  Video Thumbnails currently supports these video services:
16
 
@@ -19,8 +19,9 @@ Video Thumbnails currently supports these video services:
19
  * Justin.tv
20
  * Blip.tv
21
 
22
- Support is also included for the following plugins, with universal plugin support coming soon:
23
 
 
24
  * [Simple Video Embedder](http://wordpress.org/extend/plugins/simple-video-embedder/)
25
  * [Vimeo Shortcode](http://blog.esimplestudios.com/2010/08/embedding-vimeo-videos-in-wordpress/)
26
  * [JR Embed](http://plugins.jakeruston.co.uk/wordpress/wordpress-plugin-jr-embed/)
@@ -39,11 +40,11 @@ Some functions are available to advanced users who want to customize their theme
39
 
40
  = My theme isn't showing thumbnails, what's wrong? =
41
 
42
- The most likely problem is that your theme doesn't support post thumbnails. If thumbnails are supported, you should see a box titled "Featured Image" on the edit post page. If thumbnails aren't supported, your theme will have to be modified.
43
 
44
  = Can I use the functions outside of a loop? =
45
 
46
- Yes, but you must pass the post ID to the function as a parameter. For example: `<?php $thumbnail = get_video_thumbnail(25); ?>`
47
 
48
  = My video service/embedding plugin isn't included, can you add it? =
49
 
@@ -77,6 +78,12 @@ The Vimeo API has a rate limit, so in rare cases you may exceed this limit. Try
77
 
78
  == Changelog ==
79
 
 
 
 
 
 
 
80
  = 1.1.1 =
81
  * Fixed a bug related to scheduled posts sometimes not saving thumbnail URL to the meta field
82
 
@@ -176,7 +183,6 @@ This version adds the thumbnail URL to the post's meta data, meaning any outside
176
 
177
  == Known Issues ==
178
 
179
- * Duplicate images were being created in certain situations, but I hope that the issue has finally been resolved. Please let me know if you still are experiencing this issue.
180
  * "Scan for Video Thumbnails" button can cause errors and has been removed until it can be fixed.
181
  * Posts with thumbnails manually set are overwritten by thumbnails found by the plugin, a solution is to save the post then select a different thumbnail without saving the whole post again
182
 
@@ -186,5 +192,4 @@ This plugin is still very young, and has a future planned as the ultimate plugin
186
 
187
  * Better Blip.tv support
188
  * More services
189
- * Universal plugin compatibility
190
  * Option to display video thumbnails on the admin post list page
3
  Donate link: http://amzn.com/w/1L25YG6FO8AZ1
4
  Tags: Video, YouTube, Vimeo, Blip.tv, Justin.tv, Thumbnails
5
  Requires at least: 3.0
6
+ Tested up to: 3.1
7
+ Stable tag: 1.5
8
 
9
+ Video Thumbnails simplifies the process of automatically displaying video thumbnails in your WordPress template.
10
 
11
  == Description ==
12
 
13
+ Video Thumbnails makes it easy to automatically display video thumbnails in your template. This plugin will find the first video in your post, find the thumbnail, and can then save the video thumbnail to your media library. There's even an option to automatically set this as the featured image!
14
 
15
  Video Thumbnails currently supports these video services:
16
 
19
  * Justin.tv
20
  * Blip.tv
21
 
22
+ Video Thumbnails even works with most video embedding plugins, including:
23
 
24
+ * [Viper's Video Quicktags](http://wordpress.org/extend/plugins/vipers-video-quicktags/)
25
  * [Simple Video Embedder](http://wordpress.org/extend/plugins/simple-video-embedder/)
26
  * [Vimeo Shortcode](http://blog.esimplestudios.com/2010/08/embedding-vimeo-videos-in-wordpress/)
27
  * [JR Embed](http://plugins.jakeruston.co.uk/wordpress/wordpress-plugin-jr-embed/)
40
 
41
  = My theme isn't showing thumbnails, what's wrong? =
42
 
43
+ The most likely problem is that your theme doesn't support post thumbnails. If thumbnails are supported, you should see a box titled "Featured Image" on the edit post page. If thumbnails aren't supported, your theme will have to be modified to support Featured Images or to support one of our custom functions.
44
 
45
  = Can I use the functions outside of a loop? =
46
 
47
+ Yes, but be sure to include the post ID as a parameter. For example: `<?php $thumbnail = get_video_thumbnail(25); ?>`
48
 
49
  = My video service/embedding plugin isn't included, can you add it? =
50
 
78
 
79
  == Changelog ==
80
 
81
+ = 1.5 =
82
+ * Video thumbnails are now only saved when a post's status changes to published.
83
+ * Removed URL field from the Video Thumbnail meta box on the Edit Post Page
84
+ * Added a "Reset Video Thumbnail" button to the meta box
85
+ * Accidental duplicate images should no longer be problem
86
+
87
  = 1.1.1 =
88
  * Fixed a bug related to scheduled posts sometimes not saving thumbnail URL to the meta field
89
 
183
 
184
  == Known Issues ==
185
 
 
186
  * "Scan for Video Thumbnails" button can cause errors and has been removed until it can be fixed.
187
  * Posts with thumbnails manually set are overwritten by thumbnails found by the plugin, a solution is to save the post then select a different thumbnail without saving the whole post again
188
 
192
 
193
  * Better Blip.tv support
194
  * More services
 
195
  * Option to display video thumbnails on the admin post list page
screenshot-1.gif CHANGED
Binary file
video-thumbnails.php CHANGED
@@ -5,7 +5,7 @@ Plugin URI: http://sutherlandboswell.com/2010/11/wordpress-video-thumbnails/
5
  Description: Automatically retrieve video thumbnails for your posts and display them in your theme. Currently supports YouTube, Vimeo, Blip.tv, and Justin.tv.
6
  Author: Sutherland Boswell
7
  Author URI: http://sutherlandboswell.com
8
- Version: 1.1.1
9
  License: GPL2
10
  */
11
  /* Copyright 2010 Sutherland Boswell (email : sutherland.boswell@gmail.com)
@@ -250,33 +250,82 @@ function video_thumbnail_admin(){
250
  global $post;
251
  $custom = get_post_custom($post->ID);
252
  $video_thumbnail = $custom["_video_thumbnail"][0];
253
- ?>
254
- <p><label>Video Thumbnail URL:</label></p>
255
- <p><input type="text" size="16" name="video_thumbnail" style="width:250px;" value="<?php echo $video_thumbnail; ?>" /></p>
256
- <?php if(isset($video_thumbnail) && $video_thumbnail!='') { ?><p><img src="<?php echo $video_thumbnail; ?>" width="100%" /></p><?php } ?>
257
- <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
258
  }
259
 
260
  // Find video thumbnail when saving a post, but not on autosave
261
 
262
- add_action('save_post', 'save_video_thumbnail');
 
 
 
263
 
264
- function save_video_thumbnail(){
265
  if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) {
266
  return null;
267
  } else {
268
- global $post;
269
- $custom = get_post_custom($post->ID);
270
- $old_thumbnail = $custom["_video_thumbnail"][0];
271
- if ($old_thumbnail == '') {
272
- get_video_thumbnail($post->ID);
273
- } elseif (isset($_POST["video_thumbnail"]) && $_POST["video_thumbnail"]==$old_thumbnail) {
274
- return null;
275
- } elseif (isset($_POST["video_thumbnail"]) && $_POST["video_thumbnail"]!='') {
276
- if(!update_post_meta($post->ID, "_video_thumbnail", $_POST["video_thumbnail"])) add_post_meta($post->ID, "_video_thumbnail", $_POST["video_thumbnail"], true);
277
- } elseif (isset($_POST["video_thumbnail"]) && $_POST["video_thumbnail"]=='') {
278
- delete_post_meta($post->ID, "_video_thumbnail");
279
- }
280
  }
281
  }
282
 
5
  Description: Automatically retrieve video thumbnails for your posts and display them in your theme. Currently supports YouTube, Vimeo, Blip.tv, and Justin.tv.
6
  Author: Sutherland Boswell
7
  Author URI: http://sutherlandboswell.com
8
+ Version: 1.5
9
  License: GPL2
10
  */
11
  /* Copyright 2010 Sutherland Boswell (email : sutherland.boswell@gmail.com)
250
  global $post;
251
  $custom = get_post_custom($post->ID);
252
  $video_thumbnail = $custom["_video_thumbnail"][0];
253
+
254
+ if(isset($video_thumbnail) && $video_thumbnail!='') {
255
+ echo '<p id="video-thumbnails-preview"><img src="' . $video_thumbnail . '" width="100%" /></p>';
256
+ }
257
+
258
+ if ( get_post_status() == 'publish') {
259
+ if(isset($video_thumbnail) && $video_thumbnail!='') {
260
+ echo '<p><a href="#" id="video-thumbnails-reset" onclick="video_thumbnails_reset(\'' . $post->ID . '\');return false;">Reset Video Thumbnail</a></p>';
261
+ } else {
262
+ echo '<p id="video-thumbnails-preview">We didn\'t find a video thumbnail for this post.</p>';
263
+ echo '<p><a href="#" id="video-thumbnails-reset" onclick="video_thumbnails_reset(\'' . $post->ID . '\');return false;">Search Again</a></p>';
264
+ }
265
+ } else {
266
+ if(isset($video_thumbnail) && $video_thumbnail!='') {
267
+ echo '<p><a href="#" id="video-thumbnails-reset" onclick="video_thumbnails_reset(\'' . $post->ID . '\');return false;">Reset Video Thumbnail</a></p>';
268
+ } else {
269
+ echo '<p>A video thumbnail will be found for this post when it is published.</p>';
270
+ }
271
+ }
272
+ }
273
+
274
+ // AJAX Searching
275
+
276
+ add_action('admin_head', 'video_thumbnails_ajax');
277
+
278
+ function video_thumbnails_ajax() {
279
+ ?>
280
+ <script type="text/javascript" >
281
+ function video_thumbnails_reset(id) {
282
+
283
+ var data = {
284
+ action: 'video_thumbnails',
285
+ post_id: id
286
+ };
287
+
288
+ document.getElementById('video-thumbnails-preview').innerHTML = 'Working... <img src="<?php echo home_url('wp-admin/images/loading.gif'); ?>"/>';
289
+
290
+ // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
291
+ jQuery.post(ajaxurl, data, function(response) {
292
+ document.getElementById('video-thumbnails-preview').innerHTML = response;
293
+ });
294
+ };
295
+ </script>
296
+ <?php
297
+ }
298
+
299
+ add_action('wp_ajax_video_thumbnails', 'video_thumbnails_callback');
300
+
301
+ function video_thumbnails_callback() {
302
+ global $wpdb; // this is how you get access to the database
303
+
304
+ $post_id = $_POST['post_id'];
305
+
306
+ delete_post_meta($post_id, '_video_thumbnail');
307
+
308
+ if ( ($video_thumbnail=get_video_thumbnail($post_id)) != null ) {
309
+ echo '<img src="' . $video_thumbnail . '" width="100%" />';
310
+ } else {
311
+ echo 'We didn\'t find a video thumbnail for this post. (be sure you have saved changes first)';
312
+ }
313
+
314
+ die();
315
  }
316
 
317
  // Find video thumbnail when saving a post, but not on autosave
318
 
319
+ add_action('new_to_publish', 'save_video_thumbnail', 10, 1);
320
+ add_action('draft_to_publish', 'save_video_thumbnail', 10, 1);
321
+ add_action('pending_to_publish', 'save_video_thumbnail', 10, 1);
322
+ add_action('future_to_publish', 'save_video_thumbnail', 10, 1);
323
 
324
+ function save_video_thumbnail( $post ){
325
  if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) {
326
  return null;
327
  } else {
328
+ get_video_thumbnail($post->ID);
 
 
 
 
 
 
 
 
 
 
 
329
  }
330
  }
331