Video Thumbnails - Version 1.7.2

Version Description

  • Added support for Dailymotion and Metacafe
Download this release

Release Info

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

Code changes from version 1.7 to 1.7.2

Files changed (2) hide show
  1. readme.txt +7 -3
  2. video-thumbnails.php +58 -1
readme.txt CHANGED
@@ -1,10 +1,10 @@
1
  === Video Thumbnails ===
2
  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.1
7
- Stable tag: 1.7
8
 
9
  Video Thumbnails simplifies the process of automatically displaying video thumbnails in your WordPress template.
10
 
@@ -18,6 +18,8 @@ Video Thumbnails currently supports these video services:
18
  * Vimeo
19
  * Justin.tv
20
  * Blip.tv
 
 
21
 
22
  Video Thumbnails even works with most video embedding plugins, including:
23
 
@@ -82,6 +84,9 @@ The Vimeo API has a rate limit, so in rare cases you may exceed this limit. Try
82
 
83
  == Changelog ==
84
 
 
 
 
85
  = 1.7 =
86
  * Added new option to scan past posts for video thumbnails
87
 
@@ -199,7 +204,6 @@ This version adds the thumbnail URL to the post's meta data, meaning any outside
199
 
200
  This plugin is still very young, and has a future planned as the ultimate plugin for video thumbnails. Here's some of the planned additions:
201
 
202
- * DailyMotion and MetaCafe support coming very soon!
203
  * Better Blip.tv support
204
  * More services
205
  * Option to display video thumbnails on the admin post list page
1
  === Video Thumbnails ===
2
  Contributors: sutherlandboswell
3
  Donate link: http://amzn.com/w/1L25YG6FO8AZ1
4
+ Tags: Video, Thumbnails, YouTube, Vimeo, Blip.tv, Justin.tv, Dailymotion, Metacafe
5
  Requires at least: 3.0
6
  Tested up to: 3.1
7
+ Stable tag: 1.7.2
8
 
9
  Video Thumbnails simplifies the process of automatically displaying video thumbnails in your WordPress template.
10
 
18
  * Vimeo
19
  * Justin.tv
20
  * Blip.tv
21
+ * Dailymotion
22
+ * Metacafe
23
 
24
  Video Thumbnails even works with most video embedding plugins, including:
25
 
84
 
85
  == Changelog ==
86
 
87
+ = 1.7.2 =
88
+ * Added support for Dailymotion and Metacafe
89
+
90
  = 1.7 =
91
  * Added new option to scan past posts for video thumbnails
92
 
204
 
205
  This plugin is still very young, and has a future planned as the ultimate plugin for video thumbnails. Here's some of the planned additions:
206
 
 
207
  * Better Blip.tv support
208
  * More services
209
  * Option to display video thumbnails on the admin post list page
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.7
9
  License: GPL2
10
  */
11
  /* Copyright 2010 Sutherland Boswell (email : sutherland.boswell@gmail.com)
@@ -55,6 +55,32 @@ function getJustintvInfo($id) {
55
  return (string) $xml->clip->image_url_large;
56
  }
57
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
  // The Main Event
59
  function get_video_thumbnail($post_id=null) {
60
 
@@ -183,6 +209,37 @@ function get_video_thumbnail($post_id=null) {
183
  }
184
  }
185
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
186
  // Return the new thumbnail variable and update meta if one is found
187
  if($new_thumbnail!=null) {
188
 
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.7.2
9
  License: GPL2
10
  */
11
  /* Copyright 2010 Sutherland Boswell (email : sutherland.boswell@gmail.com)
55
  return (string) $xml->clip->image_url_large;
56
  }
57
 
58
+ // Get DailyMotion Thumbnail
59
+ function getDailyMotionThumbnail($id) {
60
+ if (!function_exists('curl_init')) {
61
+ return null;
62
+ } else {
63
+ $ch = curl_init();
64
+ curl_setopt($ch, CURLOPT_URL, "https://api.dailymotion.com/video/$id?fields=thumbnail_url");
65
+ curl_setopt($ch, CURLOPT_HEADER, 0);
66
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
67
+ curl_setopt($ch, CURLOPT_TIMEOUT, 10);
68
+ $output = curl_exec($ch);
69
+ curl_close($ch);
70
+ $output = json_decode($output);
71
+ $output = $output->thumbnail_url;
72
+ return $output;
73
+ }
74
+ };
75
+
76
+ // Metacafe
77
+ function getMetacafeThumbnail($id) {
78
+ $xml = simplexml_load_file("http://www.metacafe.com/api/item/$id/");
79
+ $result = $xml->xpath("/rss/channel/item/media:thumbnail/@url");
80
+ $thumbnail = (string) $result[0]['url'];
81
+ return $thumbnail;
82
+ };
83
+
84
  // The Main Event
85
  function get_video_thumbnail($post_id=null) {
86
 
209
  }
210
  }
211
 
212
+ // Dailymotion
213
+ if($new_thumbnail==null) {
214
+
215
+ // Dailymotion flash
216
+ preg_match('#<object[^>]+>.+?http://www.dailymotion.com/swf/video/([A-Za-z0-9]+).+?</object>#s', $markup, $matches);
217
+
218
+ // Dailymotion iframe
219
+ if(!isset($matches[1])) {
220
+ preg_match('#http://www.dailymotion.com/embed/video/([A-Za-z0-9]+)#s', $markup, $matches);
221
+ }
222
+
223
+ // Now if we've found a Dailymotion video ID, let's set the thumbnail URL
224
+ if(isset($matches[1])) {
225
+ $dailymotion_thumbnail = getDailyMotionThumbnail($matches[1]);
226
+ $new_thumbnail = strtok($dailymotion_thumbnail, '?');
227
+ }
228
+ }
229
+
230
+ // Metacafe
231
+ if($new_thumbnail==null) {
232
+
233
+ // Find ID from Metacafe embed url
234
+ preg_match('#http://www.metacafe.com/fplayer/([A-Za-z0-9\-_]+)/#s', $markup, $matches);
235
+
236
+ // Now if we've found a Metacafe video ID, let's set the thumbnail URL
237
+ if(isset($matches[1])) {
238
+ $metacafe_thumbnail = getMetacafeThumbnail($matches[1]);
239
+ $new_thumbnail = strtok($metacafe_thumbnail, '?');
240
+ }
241
+ }
242
+
243
  // Return the new thumbnail variable and update meta if one is found
244
  if($new_thumbnail!=null) {
245