Version Description
- Fixed an issue where no URL was returned when Vimeo's rate limit had been exceeded. The default image URL is now returned, but a future version of the plugin will store thumbnails locally for a better fix.
Download this release
Release Info
Developer | sutherlandboswell |
Plugin | Video Thumbnails |
Version | 0.1.3 |
Comparing to | |
See all releases |
Code changes from version 0.3 to 0.1.3
- readme.txt +11 -40
- video-thumbnails.php +12 -49
readme.txt
CHANGED
@@ -1,28 +1,24 @@
|
|
1 |
=== Video Thumbnails ===
|
2 |
Contributors: sutherlandboswell
|
3 |
-
Donate link: http://
|
4 |
Tags: Video, YouTube, Vimeo, Thumbnails
|
5 |
Requires at least: 3.0
|
6 |
Tested up to: 3.0.1
|
7 |
-
Stable tag: 0.3
|
8 |
|
9 |
Video Thumbnails is a simple plugin that makes it easier to display video thumbnails in your template.
|
10 |
|
11 |
== Description ==
|
12 |
|
13 |
-
Video Thumbnails makes it simple to display video thumbnails in your templates. Simply use `<?php video_thumbnail(); ?>` in a loop to
|
14 |
|
15 |
Video Thumbnails currently supports:
|
16 |
|
17 |
-
*
|
18 |
-
*
|
19 |
-
*
|
20 |
-
* JR Embed (this plugin seems to have disappeared)
|
21 |
-
* [Vimeo Shortcode](http://blog.esimplestudios.com/2010/08/embedding-vimeo-videos-in-wordpress/)
|
22 |
|
23 |
-
|
24 |
-
|
25 |
-
For more advanced users, the `get_video_thumbnail()` function will return null when no thumbnail is found so a conditional statement can be used to detect if a thumbnail is present and decide what to echo. Here's an example of how to only echo a thumbnail when one is found: `<?php if( ( $video_thumbnail = get_video_thumbnail() ) != null ) { echo "<img src='" . $video_thumbnail . "' />"; } ?>`
|
26 |
|
27 |
This is just a start, so don't hesitate to share suggestions and let me know if you find any problems.
|
28 |
|
@@ -30,7 +26,7 @@ This is just a start, so don't hesitate to share suggestions and let me know if
|
|
30 |
|
31 |
1. Upload the `/video-thumbnails/` directory to the `/wp-content/plugins/` directory
|
32 |
1. Activate the plugin through the 'Plugins' menu in WordPress
|
33 |
-
1.
|
34 |
|
35 |
== Frequently Asked Questions ==
|
36 |
|
@@ -38,9 +34,9 @@ This is just a start, so don't hesitate to share suggestions and let me know if
|
|
38 |
|
39 |
If the service allows a way to retrieve thumbnails, I'll do my best to add it.
|
40 |
|
41 |
-
= I
|
42 |
|
43 |
-
|
44 |
|
45 |
== Screenshots ==
|
46 |
|
@@ -48,21 +44,6 @@ Coming Soon
|
|
48 |
|
49 |
== Changelog ==
|
50 |
|
51 |
-
= 0.3 =
|
52 |
-
* Added basic support for Blip.tv auto embedded using URLs in this format: http://blip.tv/file/12345
|
53 |
-
|
54 |
-
= 0.2.3 =
|
55 |
-
* Added support for any Vimeo URL
|
56 |
-
|
57 |
-
= 0.2.2 =
|
58 |
-
* Added support for [Vimeo Shortcode](http://blog.esimplestudios.com/2010/08/embedding-vimeo-videos-in-wordpress/)
|
59 |
-
|
60 |
-
= 0.2.1 =
|
61 |
-
* Added support for Vimeo players embedded using an iframe
|
62 |
-
|
63 |
-
= 0.2 =
|
64 |
-
* Added `get_video_thumbnail()` to return the URL without echoing or return null if no thumbnail is found, making it possible to only display a thumbnail if one is found.
|
65 |
-
|
66 |
= 0.1.3 =
|
67 |
* Fixed an issue where no URL was returned when Vimeo's rate limit had been exceeded. The default image URL is now returned, but a future version of the plugin will store thumbnails locally for a better fix.
|
68 |
|
@@ -78,14 +59,4 @@ Coming Soon
|
|
78 |
|
79 |
== Known Issues ==
|
80 |
|
81 |
-
* The Vimeo API is rate limited, so the default image will be displayed when the limit has been exceeded. I'm planning to add local copies of files in a future release to solve this problem.
|
82 |
-
* While not really an issue, the current method for only displaying a thumbnail if one is found seems like it could be streamlined, so if you have any suggestions let me know.
|
83 |
-
|
84 |
-
== Roadmap ==
|
85 |
-
|
86 |
-
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:
|
87 |
-
|
88 |
-
* More comprehensive Blip.tv support
|
89 |
-
* Local thumbnail storage
|
90 |
-
* More services
|
91 |
-
* More shortcode plugins
|
1 |
=== Video Thumbnails ===
|
2 |
Contributors: sutherlandboswell
|
3 |
+
Donate link: http://example.com/
|
4 |
Tags: Video, YouTube, Vimeo, Thumbnails
|
5 |
Requires at least: 3.0
|
6 |
Tested up to: 3.0.1
|
7 |
+
Stable tag: 0.1.3
|
8 |
|
9 |
Video Thumbnails is a simple plugin that makes it easier to display video thumbnails in your template.
|
10 |
|
11 |
== Description ==
|
12 |
|
13 |
+
Video Thumbnails makes it simple to display video thumbnails in your templates. Simply use `<?php video_thumbnail(); ?>` in a loop to grab the URL of a thumbnail for a video embedded in your post.
|
14 |
|
15 |
Video Thumbnails currently supports:
|
16 |
|
17 |
+
* YouTube
|
18 |
+
* Vimeo
|
19 |
+
* JR Embed (uses `[youtube id=VIDEO_ID]` to embed videos, I've modified mine to also allow `[vimeo id=VIDEO_ID]`)
|
|
|
|
|
20 |
|
21 |
+
If no thumbnail is found, a default thumbnail is returned, which can be changed by replacing the `default.jpg` file found in your `/plugins/video-thumbnails/` directory.
|
|
|
|
|
22 |
|
23 |
This is just a start, so don't hesitate to share suggestions and let me know if you find any problems.
|
24 |
|
26 |
|
27 |
1. Upload the `/video-thumbnails/` directory to the `/wp-content/plugins/` directory
|
28 |
1. Activate the plugin through the 'Plugins' menu in WordPress
|
29 |
+
1. Place `<?php video_thumbnail(); ?>` in a loop inside your template. Because this is only a URL, you should set it as an image tag's source. Ex: `<img src="<?php video_thumbnail(); ?>" />`
|
30 |
|
31 |
== Frequently Asked Questions ==
|
32 |
|
34 |
|
35 |
If the service allows a way to retrieve thumbnails, I'll do my best to add it.
|
36 |
|
37 |
+
= I don't want a thumbnail for posts without a video, what should I do? =
|
38 |
|
39 |
+
I have several additions in mind, and better handling of this type of situation is one of them.
|
40 |
|
41 |
== Screenshots ==
|
42 |
|
44 |
|
45 |
== Changelog ==
|
46 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
= 0.1.3 =
|
48 |
* Fixed an issue where no URL was returned when Vimeo's rate limit had been exceeded. The default image URL is now returned, but a future version of the plugin will store thumbnails locally for a better fix.
|
49 |
|
59 |
|
60 |
== Known Issues ==
|
61 |
|
62 |
+
* The Vimeo API is rate limited, so the default image will be displayed when the limit has been exceeded. I'm planning to add local copies of files in a future release to solve this problem.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
video-thumbnails.php
CHANGED
@@ -5,7 +5,7 @@ Plugin URI: http://sutherlandboswell.com/2010/11/wordpress-video-thumbnails/
|
|
5 |
Description: A plugin designed to fetch video thumbnails. Use <code><?php video_thumbnail(); ?></code> in a loop to return a URL for the thumbnail of the first video in a post. Currently works with YouTube and Vimeo, and with the JR_embed plugin.
|
6 |
Author: Sutherland Boswell
|
7 |
Author URI: http://sutherlandboswell.com
|
8 |
-
Version: 0.3
|
9 |
License: GPL2
|
10 |
*/
|
11 |
/* Copyright 2010 Sutherland Boswell (email : sutherland.boswell@gmail.com)
|
@@ -38,18 +38,8 @@ function getVimeoInfo($id, $info = 'thumbnail_large') {
|
|
38 |
return $output;
|
39 |
};
|
40 |
|
41 |
-
// Blip.tv Functions
|
42 |
-
function getBliptvInfo($id) {
|
43 |
-
$xml = simplexml_load_file("http://blip.tv/file/$id?skin=rss");
|
44 |
-
$result = $xml->xpath("/rss/channel/item/media:thumbnail/@url");
|
45 |
-
foreach($result as $element) {
|
46 |
-
$thumbnail = $element["url"];
|
47 |
-
}
|
48 |
-
return $thumbnail;
|
49 |
-
}
|
50 |
-
|
51 |
// The Main Event
|
52 |
-
function
|
53 |
|
54 |
// Gets the post's content
|
55 |
$markup = get_the_content();
|
@@ -65,66 +55,39 @@ function get_video_thumbnail() {
|
|
65 |
// If no standard YouTube embed is found, checks for one embedded with JR_embed
|
66 |
if(!isset($matches[1])) {
|
67 |
preg_match('#\[youtube id=([A-Za-z0-9\-_]+)]#s', $markup, $matches);
|
68 |
-
}
|
69 |
|
70 |
-
// If we've found a YouTube video ID,
|
71 |
if(isset($matches[1])) {
|
72 |
-
|
73 |
}
|
74 |
|
75 |
// If we didn't find anything, check for a standard Vimeo embed
|
76 |
else {
|
77 |
preg_match('#<object[^>]+>.+?http://vimeo.com/moogaloop.swf\?clip_id=([A-Za-z0-9\-_]+)&.+?</object>#s', $markup, $matches);
|
78 |
|
79 |
-
// Find Vimeo embedded with iframe code
|
80 |
-
if(!isset($matches[1])) {
|
81 |
-
preg_match('#http://player.vimeo.com/video/([0-9]+)#s', $markup, $matches);
|
82 |
-
}
|
83 |
-
|
84 |
// If we still haven't found anything, check for Vimeo embedded with JR_embed
|
85 |
if(!isset($matches[1])) {
|
86 |
preg_match('#\[vimeo id=([A-Za-z0-9\-_]+)]#s', $markup, $matches);
|
87 |
-
}
|
88 |
-
|
89 |
-
// If we still haven't found anything, check for Vimeo URL
|
90 |
-
if(!isset($matches[1])) {
|
91 |
-
preg_match('#http://www.vimeo.com/([A-Za-z0-9\-_]+)#s', $markup, $matches);
|
92 |
-
}
|
93 |
-
|
94 |
-
// If we still haven't found anything, check for Vimeo shortcode
|
95 |
-
if(!isset($matches[1])) {
|
96 |
-
preg_match('#\[vimeo clip_id="([A-Za-z0-9\-_]+)"[^>]*]#s', $markup, $matches);
|
97 |
-
}
|
98 |
|
99 |
-
// Now if we've found a Vimeo ID, let's
|
100 |
if(isset($matches[1])) {
|
101 |
$vimeo_thumbnail = getVimeoInfo($matches[1], $info = 'thumbnail_large');
|
102 |
if(isset($vimeo_thumbnail)) {
|
103 |
-
|
104 |
} else {
|
105 |
// If we can't find the Vimeo thumbnail, display default
|
106 |
-
|
107 |
}
|
108 |
}
|
109 |
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
if(isset($matches[1])) {
|
114 |
-
return getBliptvInfo($matches[1]);
|
115 |
-
}
|
116 |
-
else {
|
117 |
-
return null;
|
118 |
-
}
|
119 |
}
|
120 |
}
|
121 |
|
122 |
};
|
123 |
|
124 |
-
// Echo thumbnail
|
125 |
-
function video_thumbnail() {
|
126 |
-
if( ( $video_thumbnail = get_video_thumbnail() ) == null ) { echo plugins_url() . "/video-thumbnails/default.jpg"; }
|
127 |
-
else { echo $video_thumbnail; }
|
128 |
-
};
|
129 |
-
|
130 |
?>
|
5 |
Description: A plugin designed to fetch video thumbnails. Use <code><?php video_thumbnail(); ?></code> in a loop to return a URL for the thumbnail of the first video in a post. Currently works with YouTube and Vimeo, and with the JR_embed plugin.
|
6 |
Author: Sutherland Boswell
|
7 |
Author URI: http://sutherlandboswell.com
|
8 |
+
Version: 0.1.3
|
9 |
License: GPL2
|
10 |
*/
|
11 |
/* Copyright 2010 Sutherland Boswell (email : sutherland.boswell@gmail.com)
|
38 |
return $output;
|
39 |
};
|
40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
// The Main Event
|
42 |
+
function video_thumbnail() {
|
43 |
|
44 |
// Gets the post's content
|
45 |
$markup = get_the_content();
|
55 |
// If no standard YouTube embed is found, checks for one embedded with JR_embed
|
56 |
if(!isset($matches[1])) {
|
57 |
preg_match('#\[youtube id=([A-Za-z0-9\-_]+)]#s', $markup, $matches);
|
58 |
+
};
|
59 |
|
60 |
+
// If we've found a YouTube video ID, output the thumbnail URL
|
61 |
if(isset($matches[1])) {
|
62 |
+
echo 'http://img.youtube.com/vi/' . $matches[1] . '/0.jpg';
|
63 |
}
|
64 |
|
65 |
// If we didn't find anything, check for a standard Vimeo embed
|
66 |
else {
|
67 |
preg_match('#<object[^>]+>.+?http://vimeo.com/moogaloop.swf\?clip_id=([A-Za-z0-9\-_]+)&.+?</object>#s', $markup, $matches);
|
68 |
|
|
|
|
|
|
|
|
|
|
|
69 |
// If we still haven't found anything, check for Vimeo embedded with JR_embed
|
70 |
if(!isset($matches[1])) {
|
71 |
preg_match('#\[vimeo id=([A-Za-z0-9\-_]+)]#s', $markup, $matches);
|
72 |
+
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
|
74 |
+
// Now if we've found a Vimeo ID, let's echo the thumbnail
|
75 |
if(isset($matches[1])) {
|
76 |
$vimeo_thumbnail = getVimeoInfo($matches[1], $info = 'thumbnail_large');
|
77 |
if(isset($vimeo_thumbnail)) {
|
78 |
+
echo $vimeo_thumbnail;
|
79 |
} else {
|
80 |
// If we can't find the Vimeo thumbnail, display default
|
81 |
+
echo plugins_url() . "/video-thumbnails/default.jpg";
|
82 |
}
|
83 |
}
|
84 |
|
85 |
+
// If nothing has been found, show the default
|
86 |
+
else {
|
87 |
+
echo plugins_url() . "/video-thumbnails/default.jpg";
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
}
|
89 |
}
|
90 |
|
91 |
};
|
92 |
|
|
|
|
|
|
|
|
|
|
|
|
|
93 |
?>
|