Video Thumbnails - Version 1.0.9

Version Description

  • More work on fixing the duplicate image bug
Download this release

Release Info

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

Code changes from version 1.0.8 to 1.0.9

Files changed (2) hide show
  1. readme.txt +6 -2
  2. video-thumbnails.php +15 -18
readme.txt CHANGED
@@ -4,7 +4,7 @@ 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.0.8
8
 
9
  Video Thumbnails is a simple plugin that makes it easy to automatically display video thumbnails in your template.
10
 
@@ -77,8 +77,11 @@ The Vimeo API has a rate limit, so in rare cases you may exceed this limit. Try
77
 
78
  == Changelog ==
79
 
 
 
 
80
  = 1.0.8 =
81
- * Addressed another bug that could create duplicate images when updating a post
82
 
83
  = 1.0.7 =
84
  * Fixed a bug that could create duplicate images on auto-save
@@ -167,6 +170,7 @@ This version adds the thumbnail URL to the post's meta data, meaning any outside
167
 
168
  == Known Issues ==
169
 
 
170
  * "Scan for Video Thumbnails" button can cause errors and has been removed until it can be fixed.
171
  * 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
172
 
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.0.9
8
 
9
  Video Thumbnails is a simple plugin that makes it easy to automatically display video thumbnails in your template.
10
 
77
 
78
  == Changelog ==
79
 
80
+ = 1.0.9 =
81
+ * More work on fixing the duplicate image bug
82
+
83
  = 1.0.8 =
84
+ * (Attempted to) fix another bug that could create duplicate images when updating a post
85
 
86
  = 1.0.7 =
87
  * Fixed a bug that could create duplicate images on auto-save
170
 
171
  == Known Issues ==
172
 
173
+ * 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.
174
  * "Scan for Video Thumbnails" button can cause errors and has been removed until it can be fixed.
175
  * 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
176
 
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.0.8
9
  License: GPL2
10
  */
11
  /* Copyright 2010 Sutherland Boswell (email : sutherland.boswell@gmail.com)
@@ -220,11 +220,11 @@ function get_video_thumbnail($post_id=null) {
220
  }
221
 
222
  // Add hidden custom field with thumbnail URL
223
- if(!update_post_meta($post_id, '_video_thumbnail', $new_thumbnail)) add_post_meta($post_id, '_video_thumbnail', $new_thumbnail);
224
 
225
  // Set attachment as featured image if enabled
226
  if(get_option('video_thumbnails_set_featured')==1 && get_option('video_thumbnails_save_media')==1 && get_post_meta($post_id, '_thumbnail_id', true) == '' ) {
227
- if(!update_post_meta($post_id, '_thumbnail_id', $attach_id)) add_post_meta($post_id, '_thumbnail_id', $attach_id);
228
  }
229
  }
230
  return $new_thumbnail;
@@ -257,20 +257,6 @@ function video_thumbnail_admin(){
257
  <?php
258
  }
259
 
260
- // Save Meta Details
261
-
262
- add_action('save_post', 'save_details');
263
-
264
- function save_details(){
265
- global $post;
266
- if(isset($_POST["video_thumbnail"]) && $_POST["video_thumbnail"]!='') {
267
- if(!update_post_meta($post->ID, "_video_thumbnail", $_POST["video_thumbnail"])) add_post_meta($post->ID, "_video_thumbnail", $_POST["video_thumbnail"], true);
268
- }
269
- if(isset($_POST["video_thumbnail"]) && $_POST["video_thumbnail"]=='') {
270
- delete_post_meta($post->ID, "_video_thumbnail");
271
- }
272
- }
273
-
274
  // Find video thumbnail when saving a post, but not on autosave
275
 
276
  add_action('save_post', 'save_video_thumbnail');
@@ -279,7 +265,18 @@ function save_video_thumbnail($post_ID){
279
  if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) {
280
  return $post_ID;
281
  } else {
282
- get_video_thumbnail($post_ID);
 
 
 
 
 
 
 
 
 
 
 
283
  }
284
  }
285
 
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.0.9
9
  License: GPL2
10
  */
11
  /* Copyright 2010 Sutherland Boswell (email : sutherland.boswell@gmail.com)
220
  }
221
 
222
  // Add hidden custom field with thumbnail URL
223
+ if(!update_post_meta($post_id, '_video_thumbnail', $new_thumbnail)) add_post_meta($post_id, '_video_thumbnail', $new_thumbnail, true);
224
 
225
  // Set attachment as featured image if enabled
226
  if(get_option('video_thumbnails_set_featured')==1 && get_option('video_thumbnails_save_media')==1 && get_post_meta($post_id, '_thumbnail_id', true) == '' ) {
227
+ if(!update_post_meta($post_id, '_thumbnail_id', $attach_id)) add_post_meta($post_id, '_thumbnail_id', $attach_id, true);
228
  }
229
  }
230
  return $new_thumbnail;
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');
265
  if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) {
266
  return $post_ID;
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 $post_ID;
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