Version Description
- Fixed an issue where existing thumbnails (such as ones manually set by the user) would be replaced by Video Thumbnails
- Added a checks to see if cURL is running
Download this release
Release Info
Developer | sutherlandboswell |
Plugin | Video Thumbnails |
Version | 1.0.3 |
Comparing to | |
See all releases |
Code changes from version 1.0 to 1.0.3
- readme.txt +10 -2
- video-thumbnails.php +38 -77
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 |
|
9 |
Video Thumbnails is a simple plugin that makes it easy to automatically display video thumbnails in your template.
|
10 |
|
@@ -77,6 +77,13 @@ The Vimeo API has a rate limit, so in rare cases you may exceed this limit. Try
|
|
77 |
|
78 |
== Changelog ==
|
79 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
= 1.0 =
|
81 |
* Video Thumbnails can now be stored in the local WordPress media library
|
82 |
* Video Thumbnails stored locally can automatically be set as the featured image, making it support many themes automatically
|
@@ -144,7 +151,8 @@ This version adds the thumbnail URL to the post's meta data, meaning any outside
|
|
144 |
|
145 |
== Known Issues ==
|
146 |
|
147 |
-
*
|
|
|
148 |
|
149 |
== Roadmap ==
|
150 |
|
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.3
|
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.3 =
|
81 |
+
* Fixed an issue where existing thumbnails (such as ones manually set by the user) would be replaced by Video Thumbnails
|
82 |
+
* Added a checks to see if cURL is running
|
83 |
+
|
84 |
+
= 1.0.1 =
|
85 |
+
* Removed "Scan for Video Thumbnails" button from settings page until improvements can be made
|
86 |
+
|
87 |
= 1.0 =
|
88 |
* Video Thumbnails can now be stored in the local WordPress media library
|
89 |
* Video Thumbnails stored locally can automatically be set as the featured image, making it support many themes automatically
|
151 |
|
152 |
== Known Issues ==
|
153 |
|
154 |
+
* "Scan for Video Thumbnails" button can cause errors and has been removed until it can be fixed.
|
155 |
+
* 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
|
156 |
|
157 |
== Roadmap ==
|
158 |
|
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
|
9 |
License: GPL2
|
10 |
*/
|
11 |
/* Copyright 2010 Sutherland Boswell (email : sutherland.boswell@gmail.com)
|
@@ -26,16 +26,19 @@ License: GPL2
|
|
26 |
|
27 |
// Get Vimeo Thumbnail
|
28 |
function getVimeoInfo($id, $info = 'thumbnail_large') {
|
29 |
-
if (!function_exists('curl_init'))
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
|
|
|
|
|
|
39 |
};
|
40 |
|
41 |
// Blip.tv Functions
|
@@ -95,14 +98,18 @@ function get_video_thumbnail($post_id=null) {
|
|
95 |
$youtube_thumbnail = 'http://img.youtube.com/vi/' . $matches[1] . '/0.jpg';
|
96 |
|
97 |
// Check to make sure it's an actual thumbnail
|
98 |
-
|
99 |
-
curl_setopt($ch, CURLOPT_NOBODY, true);
|
100 |
-
curl_exec($ch);
|
101 |
-
$retcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
102 |
-
// $retcode > 400 -> not found, $retcode = 200, found.
|
103 |
-
curl_close($ch);
|
104 |
-
if($retcode==200) {
|
105 |
$new_thumbnail = $youtube_thumbnail;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
106 |
}
|
107 |
}
|
108 |
|
@@ -202,10 +209,8 @@ function get_video_thumbnail($post_id=null) {
|
|
202 |
if(!update_post_meta($post_id, '_video_thumbnail', $new_thumbnail)) add_post_meta($post_id, '_video_thumbnail', $new_thumbnail);
|
203 |
|
204 |
// Set attachment as featured image if enabled
|
205 |
-
if(get_option('video_thumbnails_set_featured')==1 && get_option('video_thumbnails_save_media')==1) {
|
206 |
-
if(!
|
207 |
-
if(!update_post_meta($post_id, '_thumbnail_id', $attach_id)) add_post_meta($post_id, '_thumbnail_id', $attach_id);
|
208 |
-
}
|
209 |
}
|
210 |
}
|
211 |
return $new_thumbnail;
|
@@ -275,6 +280,17 @@ function video_thumbnails_deactivate() {
|
|
275 |
delete_option('video_thumbnails_set_featured');
|
276 |
}
|
277 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
278 |
// Aministration
|
279 |
|
280 |
add_action('admin_menu', 'video_thumbnails_menu');
|
@@ -332,61 +348,6 @@ function video_thumbnails_checkbox_option($option_name, $option_description) { ?
|
|
332 |
|
333 |
<input type="hidden" name="action" value="update" />
|
334 |
<input type="hidden" name="page_options" value="video_thumbnails_save_media,video_thumbnails_set_featured" />
|
335 |
-
|
336 |
-
</form>
|
337 |
-
|
338 |
-
<h3>Scan all posts</h3>
|
339 |
-
|
340 |
-
<p>Click to scan past posts for video thumbnails (this may take awhile)</p>
|
341 |
-
<?php
|
342 |
-
|
343 |
-
// If the button was clicked
|
344 |
-
if ( ! empty( $_POST['scan-for-thumbnails'] ) ) {
|
345 |
-
// Capability check
|
346 |
-
if ( !current_user_can( 'manage_options' ) )
|
347 |
-
wp_die( __( 'Cheatin’ uh?' ) );
|
348 |
-
|
349 |
-
// Form nonce check
|
350 |
-
check_admin_referer( 'scan-for-thumbnails' );
|
351 |
-
|
352 |
-
query_posts('posts_per_page=-1');
|
353 |
-
|
354 |
-
$home_url = str_replace("/","\/",home_url());
|
355 |
-
|
356 |
-
echo '<p><ol>';
|
357 |
-
while (have_posts()) : the_post();
|
358 |
-
echo '<li>';
|
359 |
-
echo '<strong>' . get_the_title() . '</strong> - ';
|
360 |
-
if( ($video_thumbnail=get_video_thumbnail())!=null ) {
|
361 |
-
echo 'Found one, ';
|
362 |
-
if (preg_match('/^'.$home_url.'/', $video_thumbnail)) {
|
363 |
-
echo 'and it\'s already local.';
|
364 |
-
} else {
|
365 |
-
echo 'but it\'s remote. ';
|
366 |
-
if(delete_post_meta(get_the_ID(), '_video_thumbnail')) {
|
367 |
-
echo 'Remote file has been removed, ';
|
368 |
-
}
|
369 |
-
if( ($video_thumbnail=get_video_thumbnail())!=null ) {
|
370 |
-
echo 'and a local one has been created at ' . $video_thumbnail;
|
371 |
-
} else {
|
372 |
-
echo 'but no new one could be found. Did you remove the video?';
|
373 |
-
}
|
374 |
-
}
|
375 |
-
} else {
|
376 |
-
echo 'None found.';
|
377 |
-
}
|
378 |
-
echo '</li>';
|
379 |
-
endwhile;
|
380 |
-
echo '</ol></p>';
|
381 |
-
|
382 |
-
}
|
383 |
-
|
384 |
-
?>
|
385 |
-
|
386 |
-
<form method="post" action="">
|
387 |
-
<?php wp_nonce_field('scan-for-thumbnails') ?>
|
388 |
-
|
389 |
-
<p><input type="submit" class="button" name="scan-for-thumbnails" id="scan-for-thumbnails" value="Scan for Video Thumbnails" /></p>
|
390 |
|
391 |
</form>
|
392 |
|
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.3
|
9 |
License: GPL2
|
10 |
*/
|
11 |
/* Copyright 2010 Sutherland Boswell (email : sutherland.boswell@gmail.com)
|
26 |
|
27 |
// Get Vimeo Thumbnail
|
28 |
function getVimeoInfo($id, $info = 'thumbnail_large') {
|
29 |
+
if (!function_exists('curl_init')) {
|
30 |
+
return null;
|
31 |
+
} else {
|
32 |
+
$ch = curl_init();
|
33 |
+
curl_setopt($ch, CURLOPT_URL, "http://vimeo.com/api/v2/video/$id.php");
|
34 |
+
curl_setopt($ch, CURLOPT_HEADER, 0);
|
35 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
36 |
+
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
|
37 |
+
$output = unserialize(curl_exec($ch));
|
38 |
+
$output = $output[0][$info];
|
39 |
+
curl_close($ch);
|
40 |
+
return $output;
|
41 |
+
}
|
42 |
};
|
43 |
|
44 |
// Blip.tv Functions
|
98 |
$youtube_thumbnail = 'http://img.youtube.com/vi/' . $matches[1] . '/0.jpg';
|
99 |
|
100 |
// Check to make sure it's an actual thumbnail
|
101 |
+
if (!function_exists('curl_init')) {
|
|
|
|
|
|
|
|
|
|
|
|
|
102 |
$new_thumbnail = $youtube_thumbnail;
|
103 |
+
} else {
|
104 |
+
$ch = curl_init($youtube_thumbnail);
|
105 |
+
curl_setopt($ch, CURLOPT_NOBODY, true);
|
106 |
+
curl_exec($ch);
|
107 |
+
$retcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
108 |
+
// $retcode > 400 -> not found, $retcode = 200, found.
|
109 |
+
curl_close($ch);
|
110 |
+
if($retcode==200) {
|
111 |
+
$new_thumbnail = $youtube_thumbnail;
|
112 |
+
}
|
113 |
}
|
114 |
}
|
115 |
|
209 |
if(!update_post_meta($post_id, '_video_thumbnail', $new_thumbnail)) add_post_meta($post_id, '_video_thumbnail', $new_thumbnail);
|
210 |
|
211 |
// Set attachment as featured image if enabled
|
212 |
+
if(get_option('video_thumbnails_set_featured')==1 && get_option('video_thumbnails_save_media')==1 && get_post_meta($post_id, '_thumbnail_id', true) == '' ) {
|
213 |
+
if(!update_post_meta($post_id, '_thumbnail_id', $attach_id)) add_post_meta($post_id, '_thumbnail_id', $attach_id);
|
|
|
|
|
214 |
}
|
215 |
}
|
216 |
return $new_thumbnail;
|
280 |
delete_option('video_thumbnails_set_featured');
|
281 |
}
|
282 |
|
283 |
+
// Check for cURL
|
284 |
+
|
285 |
+
register_activation_hook(__FILE__,'video_thumbnails_curl_check');
|
286 |
+
|
287 |
+
function video_thumbnails_curl_check(){
|
288 |
+
if (!function_exists('curl_init')) {
|
289 |
+
deactivate_plugins(basename(__FILE__)); // Deactivate ourself
|
290 |
+
wp_die("Sorry, but this plugin requires cURL to be activated on your server.<BR><BR>Google should be able to help you.");
|
291 |
+
}
|
292 |
+
}
|
293 |
+
|
294 |
// Aministration
|
295 |
|
296 |
add_action('admin_menu', 'video_thumbnails_menu');
|
348 |
|
349 |
<input type="hidden" name="action" value="update" />
|
350 |
<input type="hidden" name="page_options" value="video_thumbnails_save_media,video_thumbnails_set_featured" />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
351 |
|
352 |
</form>
|
353 |
|