Video Thumbnails - Version 2.0.7

Version Description

  • Fix for bug that prevented featured images from being set for posts imported by AYVP
Download this release

Release Info

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

Code changes from version 2.0.6 to 2.0.7

Files changed (2) hide show
  1. readme.txt +7 -3
  2. video-thumbnails.php +21 -21
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: sutherlandboswell
3
  Donate link: http://wie.ly/u/donate
4
  Tags: Video, Thumbnails, YouTube, Vimeo, Blip, Justin.tv, Dailymotion, Metacafe, Image, Featured Image, Post Thumbnail
5
  Requires at least: 3.1
6
- Tested up to: 3.5.1
7
- Stable tag: 2.0.6
8
 
9
  Video Thumbnails simplifies the process of automatically displaying video thumbnails in your WordPress template.
10
 
@@ -29,8 +29,9 @@ Video Thumbnails currently supports these video services:
29
 
30
  Video Thumbnails even works with most video embedding plugins, including:
31
 
32
- * [Automatic Youtube Video Posts Plugin](http://wordpress.org/extend/plugins/automatic-youtube-video-posts/)
33
  * [Viper's Video Quicktags](http://wordpress.org/extend/plugins/vipers-video-quicktags/)
 
34
  * [Simple Video Embedder](http://wordpress.org/extend/plugins/simple-video-embedder/)
35
  * [Vimeo Shortcode](http://blog.esimplestudios.com/2010/08/embedding-vimeo-videos-in-wordpress/)
36
  * [WP YouTube Lyte](http://wordpress.org/extend/plugins/wp-youtube-lyte/)
@@ -96,6 +97,9 @@ The Vimeo API has a rate limit, so in rare cases you may exceed this limit. Try
96
 
97
  == Changelog ==
98
 
 
 
 
99
  = 2.0.6 =
100
  * Fix for "Fatal error: Cannot use object of type WP_Error as array" bug
101
 
3
  Donate link: http://wie.ly/u/donate
4
  Tags: Video, Thumbnails, YouTube, Vimeo, Blip, Justin.tv, Dailymotion, Metacafe, Image, Featured Image, Post Thumbnail
5
  Requires at least: 3.1
6
+ Tested up to: 3.6
7
+ Stable tag: 2.0.7
8
 
9
  Video Thumbnails simplifies the process of automatically displaying video thumbnails in your WordPress template.
10
 
29
 
30
  Video Thumbnails even works with most video embedding plugins, including:
31
 
32
+ * [Refactored Video Importer](https://refactored.co/plugins/video-importer)
33
  * [Viper's Video Quicktags](http://wordpress.org/extend/plugins/vipers-video-quicktags/)
34
+ * [Automatic Youtube Video Posts Plugin](http://wordpress.org/extend/plugins/automatic-youtube-video-posts/)
35
  * [Simple Video Embedder](http://wordpress.org/extend/plugins/simple-video-embedder/)
36
  * [Vimeo Shortcode](http://blog.esimplestudios.com/2010/08/embedding-vimeo-videos-in-wordpress/)
37
  * [WP YouTube Lyte](http://wordpress.org/extend/plugins/wp-youtube-lyte/)
97
 
98
  == Changelog ==
99
 
100
+ = 2.0.7 =
101
+ * Fix for bug that prevented featured images from being set for posts imported by AYVP
102
+
103
  = 2.0.6 =
104
  * Fix for "Fatal error: Cannot use object of type WP_Error as array" bug
105
 
video-thumbnails.php CHANGED
@@ -5,7 +5,7 @@ Plugin URI: http://refactored.co/plugins/video-thumbnails
5
  Description: Automatically retrieve video thumbnails for your posts and display them in your theme. Currently supports YouTube, Vimeo, Facebook, Blip.tv, Justin.tv, Dailymotion, Metacafe, Wistia, Youku, Funny or Die, and MPORA.
6
  Author: Sutherland Boswell
7
  Author URI: http://sutherlandboswell.com
8
- Version: 2.0.6
9
  License: GPL2
10
  */
11
  /* Copyright 2013 Sutherland Boswell (email : sutherland.boswell@gmail.com)
@@ -28,7 +28,7 @@ License: GPL2
28
 
29
  define( 'VIDEO_THUMBNAILS_PATH', dirname(__FILE__) );
30
  define( 'VIDEO_THUMBNAILS_FIELD', '_video_thumbnail' );
31
- define( 'VIDEO_THUMBNAILS_VERSION', '2.0.6' );
32
 
33
  // Providers
34
  require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-video-thumbnails-providers.php' );
@@ -58,12 +58,7 @@ class Video_Thumbnails {
58
  add_action( 'admin_init', array( &$this, 'meta_box_init' ) );
59
 
60
  // Add actions to save video thumbnails when saving
61
- add_action( 'new_to_draft', array( &$this, 'save_video_thumbnail' ), 10, 1 );
62
- add_action( 'new_to_publish', array( &$this, 'save_video_thumbnail' ), 10, 1 );
63
- add_action( 'draft_to_publish', array( &$this, 'save_video_thumbnail' ), 10, 1 );
64
- add_action( 'pending_to_publish', array( &$this, 'save_video_thumbnail' ), 10, 1 );
65
- add_action( 'future_to_publish', array( &$this, 'save_video_thumbnail' ), 10, 1 );
66
- add_action( 'private_to_publish', array( &$this, 'save_video_thumbnail' ), 10, 1 );
67
 
68
  // Add actions to save video thumbnails when posting from XML-RPC (this action passes the post ID as an argument so 'get_video_thumbnail' is used instead)
69
  add_action( 'xmlrpc_publish_post', 'get_video_thumbnail', 10, 1 );
@@ -165,8 +160,11 @@ class Video_Thumbnails {
165
  if ( !update_post_meta( $post_id, VIDEO_THUMBNAILS_FIELD, $new_thumbnail ) ) add_post_meta( $post_id, VIDEO_THUMBNAILS_FIELD, $new_thumbnail, true );
166
 
167
  // Set attachment as featured image if enabled
168
- if ( $this->settings->options['set_featured'] == 1 && $this->settings->options['save_media'] == 1 && !get_post_thumbnail_id( $post_id ) ) {
169
- set_post_thumbnail( $post_id, $attachment_id );
 
 
 
170
  }
171
  }
172
  return $new_thumbnail;
@@ -174,18 +172,20 @@ class Video_Thumbnails {
174
  }
175
  }
176
 
177
- // Runs when post is saved
178
- function save_video_thumbnail( $post ) {
179
- $post_type = get_post_type( $post->ID );
180
- if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
181
- return null;
 
 
 
 
 
 
 
182
  } else {
183
- // Check that Video Thumbnails are enabled for current post type
184
- if ( in_array( $post_type, (array) $this->settings->options['post_types'] ) || $post_type == $this->settings->options['post_types'] ) {
185
- get_video_thumbnail( $post->ID );
186
- } else {
187
- return null;
188
- }
189
  }
190
  }
191
 
5
  Description: Automatically retrieve video thumbnails for your posts and display them in your theme. Currently supports YouTube, Vimeo, Facebook, Blip.tv, Justin.tv, Dailymotion, Metacafe, Wistia, Youku, Funny or Die, and MPORA.
6
  Author: Sutherland Boswell
7
  Author URI: http://sutherlandboswell.com
8
+ Version: 2.0.7
9
  License: GPL2
10
  */
11
  /* Copyright 2013 Sutherland Boswell (email : sutherland.boswell@gmail.com)
28
 
29
  define( 'VIDEO_THUMBNAILS_PATH', dirname(__FILE__) );
30
  define( 'VIDEO_THUMBNAILS_FIELD', '_video_thumbnail' );
31
+ define( 'VIDEO_THUMBNAILS_VERSION', '2.0.7' );
32
 
33
  // Providers
34
  require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-video-thumbnails-providers.php' );
58
  add_action( 'admin_init', array( &$this, 'meta_box_init' ) );
59
 
60
  // Add actions to save video thumbnails when saving
61
+ add_action( 'save_post', array( &$this, 'save_video_thumbnail' ), 100, 1 );
 
 
 
 
 
62
 
63
  // Add actions to save video thumbnails when posting from XML-RPC (this action passes the post ID as an argument so 'get_video_thumbnail' is used instead)
64
  add_action( 'xmlrpc_publish_post', 'get_video_thumbnail', 10, 1 );
160
  if ( !update_post_meta( $post_id, VIDEO_THUMBNAILS_FIELD, $new_thumbnail ) ) add_post_meta( $post_id, VIDEO_THUMBNAILS_FIELD, $new_thumbnail, true );
161
 
162
  // Set attachment as featured image if enabled
163
+ if ( $this->settings->options['set_featured'] == 1 && $this->settings->options['save_media'] == 1 ) {
164
+ // Make sure there isn't already a post thumbnail
165
+ if ( intval( get_post_thumbnail_id( $post_id ) ) === 0 ) {
166
+ set_post_thumbnail( $post_id, $attachment_id );
167
+ }
168
  }
169
  }
170
  return $new_thumbnail;
172
  }
173
  }
174
 
175
+ /**
176
+ * Gets a video thumbnail when a published post is saved
177
+ * @param int $post_id The post ID
178
+ */
179
+ function save_video_thumbnail( $post_id ) {
180
+ // Don't save video thumbnails during autosave or for unpublished posts
181
+ if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return null;
182
+ if ( get_post_status( $post_id ) != 'publish' ) return null;
183
+ // Check that Video Thumbnails are enabled for current post type
184
+ $post_type = get_post_type( $post_id );
185
+ if ( in_array( $post_type, (array) $this->settings->options['post_types'] ) || $post_type == $this->settings->options['post_types'] ) {
186
+ $this->get_video_thumbnail( $post_id );
187
  } else {
188
+ return null;
 
 
 
 
 
189
  }
190
  }
191