Version Description
- Added support for YouTube videos using LazyYT.js
- Better Google Drive support
- Filenames now have non-latin characters removed and use the post ID as a fallback
- Fixed bug caused by internal server error during bulk scans
- Improved performance of provider tests
Download this release
Release Info
Developer | sutherlandboswell |
Plugin | Video Thumbnails |
Version | 2.4.1 |
Comparing to | |
See all releases |
Code changes from version 2.4 to 2.4.1
js/bulk.js
CHANGED
@@ -106,20 +106,30 @@ jQuery(function ($) {
|
|
106 |
post_id: this.posts[this.currentItem]
|
107 |
};
|
108 |
var self = this;
|
109 |
-
$.
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
if ( result.
|
116 |
-
self.
|
117 |
} else {
|
118 |
-
self.
|
|
|
|
|
|
|
|
|
|
|
119 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
120 |
}
|
121 |
-
self.updateStats();
|
122 |
-
self.scheduleNextItem();
|
123 |
});
|
124 |
|
125 |
} else {
|
106 |
post_id: this.posts[this.currentItem]
|
107 |
};
|
108 |
var self = this;
|
109 |
+
$.ajax({
|
110 |
+
url: ajaxurl,
|
111 |
+
type: "POST",
|
112 |
+
data: data,
|
113 |
+
success: function(response) {
|
114 |
+
var result = $.parseJSON( response );
|
115 |
+
if ( result.length == 0 ) {
|
116 |
+
self.log( '[' + self.posts[self.currentItem] + '] No thumbnail' );
|
117 |
} else {
|
118 |
+
self.log( '[' + self.posts[self.currentItem] + '] ' + result.url + ' (' + result.type + ')' );
|
119 |
+
if ( result.type == 'new' ) {
|
120 |
+
self.newThumbnails++;
|
121 |
+
} else {
|
122 |
+
self.existingThumbnails++;
|
123 |
+
}
|
124 |
}
|
125 |
+
self.updateStats();
|
126 |
+
self.scheduleNextItem();
|
127 |
+
},
|
128 |
+
error: function(jqXHR, textStatus, errorThrown) {
|
129 |
+
self.log( '[' + self.posts[self.currentItem] + '] Error: ' + errorThrown );
|
130 |
+
self.updateStats();
|
131 |
+
self.scheduleNextItem();
|
132 |
}
|
|
|
|
|
133 |
});
|
134 |
|
135 |
} else {
|
php/class-video-thumbnails-settings.php
CHANGED
@@ -202,8 +202,14 @@ class Video_Thumbnails_Settings {
|
|
202 |
} else {
|
203 |
$result = explode( '?', $result );
|
204 |
$result = $result[0];
|
205 |
-
$result_hash =
|
206 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
207 |
if ( $matched ) {
|
208 |
echo '<td style="color:green;">✔ Passed</td>';
|
209 |
$passed++;
|
202 |
} else {
|
203 |
$result = explode( '?', $result );
|
204 |
$result = $result[0];
|
205 |
+
$result_hash = false;
|
206 |
+
if ( $result == $test_case['expected'] ) {
|
207 |
+
$matched = true;
|
208 |
+
} else {
|
209 |
+
$result_hash = $this->get_file_hash( $result );
|
210 |
+
$matched = ( $result_hash == $test_case['expected_hash'] ? true : false );
|
211 |
+
}
|
212 |
+
|
213 |
if ( $matched ) {
|
214 |
echo '<td style="color:green;">✔ Passed</td>';
|
215 |
$passed++;
|
php/providers/class-googledrive-thumbnails.php
CHANGED
@@ -48,6 +48,7 @@ class GoogleDrive_Thumbnails extends Video_Thumbnails_Providers {
|
|
48 |
public $regexes = array(
|
49 |
'#(?:https?:)?//docs\.google\.com/(?:a/[^/]+/)?file/d/([A-Za-z0-9]+)/preview#', // iFrame URL
|
50 |
'#(?:https?:)?//video\.google\.com/get_player\?docid=([A-Za-z0-9]+)#', // Flash URL
|
|
|
51 |
);
|
52 |
|
53 |
// Thumbnail URL
|
@@ -91,6 +92,12 @@ class GoogleDrive_Thumbnails extends Video_Thumbnails_Providers {
|
|
91 |
'expected_hash' => '31cf8e05f981c1beb6e04823ad54d267',
|
92 |
'name' => 'Flash embed'
|
93 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
);
|
95 |
|
96 |
}
|
48 |
public $regexes = array(
|
49 |
'#(?:https?:)?//docs\.google\.com/(?:a/[^/]+/)?file/d/([A-Za-z0-9]+)/preview#', // iFrame URL
|
50 |
'#(?:https?:)?//video\.google\.com/get_player\?docid=([A-Za-z0-9]+)#', // Flash URL
|
51 |
+
'#<param value="(?:[^"]+)?docid=([A-Za-z0-9]+)(?:[^"]+)?" name="flashvars">#', // Flash (YouTube player)
|
52 |
);
|
53 |
|
54 |
// Thumbnail URL
|
92 |
'expected_hash' => '31cf8e05f981c1beb6e04823ad54d267',
|
93 |
'name' => 'Flash embed'
|
94 |
),
|
95 |
+
array(
|
96 |
+
'markup' => '<object style="" id="" data="https://youtube.com/get_player?el=leaf" wmode="opaque" allowfullscreen="true" allowscriptaccess="always" type="application/x-shockwave-flash" height="720px" width="1280px"><param value="true" name="allowFullScreen"><param value="always" name="allowscriptaccess"><param value="opaque" name="wmode"><param value="allow_embed=0&partnerid=30&autoplay=1&showinfo=0&docid=0B9VJd4kStxIVellHZEdXdmdSamM&el=leaf" name="flashvars"></object>',
|
97 |
+
'expected' => 'https://lh5.googleusercontent.com/mHn5gESachhZHi-kbPCRbR6RVXZm3bR7oNNXL97LyYjpzV3Eqty71J2Waw0DPnXKKw=s480',
|
98 |
+
'expected_hash' => '2d0ad4881e4b38de0510a103d2f40dd1',
|
99 |
+
'name' => 'Flash embed (YouTube player)'
|
100 |
+
),
|
101 |
);
|
102 |
|
103 |
}
|
php/providers/class-wistia-thumbnails.php
CHANGED
@@ -79,7 +79,7 @@ class Wistia_Thumbnails extends Video_Thumbnails_Providers {
|
|
79 |
public $test_cases = array(
|
80 |
array(
|
81 |
'markup' => '<iframe src="http://fast.wistia.net/embed/iframe/po4utu3zde?controlsVisibleOnLoad=true&version=v1&videoHeight=360&videoWidth=640&volumeControl=true" allowtransparency="true" frameborder="0" scrolling="no" class="wistia_embed" name="wistia_embed" width="640" height="360"></iframe>',
|
82 |
-
'expected' => '
|
83 |
'expected_hash' => 'bc4a2cec9ac97e2ccdae2c7387a01cb4',
|
84 |
'name' => 'Inline player'
|
85 |
),
|
79 |
public $test_cases = array(
|
80 |
array(
|
81 |
'markup' => '<iframe src="http://fast.wistia.net/embed/iframe/po4utu3zde?controlsVisibleOnLoad=true&version=v1&videoHeight=360&videoWidth=640&volumeControl=true" allowtransparency="true" frameborder="0" scrolling="no" class="wistia_embed" name="wistia_embed" width="640" height="360"></iframe>',
|
82 |
+
'expected' => 'https://embed-ssl.wistia.com/deliveries/6928fcba8355e38de4d95863a659e1de23cb2071.jpg',
|
83 |
'expected_hash' => 'bc4a2cec9ac97e2ccdae2c7387a01cb4',
|
84 |
'name' => 'Inline player'
|
85 |
),
|
php/providers/class-youtube-thumbnails.php
CHANGED
@@ -38,7 +38,8 @@ class YouTube_Thumbnails extends Video_Thumbnails_Providers {
|
|
38 |
'#(?:https?:)?//www\.youtube(?:\-nocookie)?\.com/(?:v|e|embed)/([A-Za-z0-9\-_]+)#', // Comprehensive search for both iFrame and old school embeds
|
39 |
'#(?:https?(?:a|vh?)?://)?(?:www\.)?youtube(?:\-nocookie)?\.com/watch\?.*v=([A-Za-z0-9\-_]+)#', // Any YouTube URL. After http(s) support a or v for Youtube Lyte and v or vh for Smart Youtube plugin
|
40 |
'#(?:https?(?:a|vh?)?://)?youtu\.be/([A-Za-z0-9\-_]+)#', // Any shortened youtu.be URL. After http(s) a or v for Youtube Lyte and v or vh for Smart Youtube plugin
|
41 |
-
'#<div class="lyte" id="([A-Za-z0-9\-_]+)"#' // YouTube Lyte
|
|
|
42 |
);
|
43 |
|
44 |
// Thumbnail URL
|
38 |
'#(?:https?:)?//www\.youtube(?:\-nocookie)?\.com/(?:v|e|embed)/([A-Za-z0-9\-_]+)#', // Comprehensive search for both iFrame and old school embeds
|
39 |
'#(?:https?(?:a|vh?)?://)?(?:www\.)?youtube(?:\-nocookie)?\.com/watch\?.*v=([A-Za-z0-9\-_]+)#', // Any YouTube URL. After http(s) support a or v for Youtube Lyte and v or vh for Smart Youtube plugin
|
40 |
'#(?:https?(?:a|vh?)?://)?youtu\.be/([A-Za-z0-9\-_]+)#', // Any shortened youtu.be URL. After http(s) a or v for Youtube Lyte and v or vh for Smart Youtube plugin
|
41 |
+
'#<div class="lyte" id="([A-Za-z0-9\-_]+)"#', // YouTube Lyte
|
42 |
+
'#data-youtube-id="([A-Za-z0-9\-_]+)"#' // LazyYT.js
|
43 |
);
|
44 |
|
45 |
// Thumbnail URL
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: http://wie.ly/u/donate
|
|
4 |
Tags: Video, Thumbnails, YouTube, Vimeo, Vine, Twitch, Dailymotion, Youku, Rutube, Featured Image
|
5 |
Requires at least: 3.1
|
6 |
Tested up to: 3.8
|
7 |
-
Stable tag: 2.4
|
8 |
|
9 |
Video Thumbnails simplifies the process of automatically displaying video thumbnails in your WordPress template.
|
10 |
|
@@ -111,6 +111,13 @@ The Vimeo API has a rate limit, so in rare cases you may exceed this limit. Try
|
|
111 |
|
112 |
== Changelog ==
|
113 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
114 |
= 2.4 =
|
115 |
* Added support for Vine
|
116 |
* Added support for Google Drive videos
|
4 |
Tags: Video, Thumbnails, YouTube, Vimeo, Vine, Twitch, Dailymotion, Youku, Rutube, Featured Image
|
5 |
Requires at least: 3.1
|
6 |
Tested up to: 3.8
|
7 |
+
Stable tag: 2.4.1
|
8 |
|
9 |
Video Thumbnails simplifies the process of automatically displaying video thumbnails in your WordPress template.
|
10 |
|
111 |
|
112 |
== Changelog ==
|
113 |
|
114 |
+
= 2.4.1 =
|
115 |
+
* Added support for YouTube videos using LazyYT.js
|
116 |
+
* Better Google Drive support
|
117 |
+
* Filenames now have non-latin characters removed and use the post ID as a fallback
|
118 |
+
* Fixed bug caused by internal server error during bulk scans
|
119 |
+
* Improved performance of provider tests
|
120 |
+
|
121 |
= 2.4 =
|
122 |
* Added support for Vine
|
123 |
* Added support for Google Drive videos
|
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. Supports YouTube, Vimeo, Facebook, Vine, Justin.tv, Twitch, Dailymotion, Metacafe, Blip, Google Drive, Funny or Die, CollegeHumor, MPORA, Wistia, Youku, and Rutube.
|
6 |
Author: Sutherland Boswell
|
7 |
Author URI: http://sutherlandboswell.com
|
8 |
-
Version: 2.4
|
9 |
License: GPL2
|
10 |
*/
|
11 |
/* Copyright 2014 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.4' );
|
32 |
|
33 |
// Providers
|
34 |
require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-video-thumbnails-providers.php' );
|
@@ -110,7 +110,7 @@ class Video_Thumbnails {
|
|
110 |
|
111 |
// Construct the meta box
|
112 |
function meta_box() {
|
113 |
-
|
114 |
// Add hidden troubleshooting info
|
115 |
add_thickbox();
|
116 |
?>
|
@@ -128,8 +128,6 @@ class Video_Thumbnails {
|
|
128 |
</ol>
|
129 |
</div>
|
130 |
<?php
|
131 |
-
|
132 |
-
global $post;
|
133 |
$custom = get_post_custom( $post->ID );
|
134 |
if ( isset( $custom[VIDEO_THUMBNAILS_FIELD][0] ) ) $video_thumbnail = $custom[VIDEO_THUMBNAILS_FIELD][0];
|
135 |
|
@@ -284,6 +282,23 @@ class Video_Thumbnails {
|
|
284 |
}
|
285 |
}
|
286 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
287 |
// Saves to media library
|
288 |
public function save_to_media_library( $image_url, $post_id ) {
|
289 |
|
@@ -304,8 +319,8 @@ class Video_Thumbnails {
|
|
304 |
if ( $image_type == 'image/jpeg' ) $image_extension = '.jpg';
|
305 |
elseif ( $image_type == 'image/png' ) $image_extension = '.png';
|
306 |
|
307 |
-
// Construct a file name
|
308 |
-
$new_filename =
|
309 |
|
310 |
// Save the image bits using the new filename
|
311 |
$upload = wp_upload_bits( $new_filename, null, $image_contents );
|
5 |
Description: Automatically retrieve video thumbnails for your posts and display them in your theme. Supports YouTube, Vimeo, Facebook, Vine, Justin.tv, Twitch, Dailymotion, Metacafe, Blip, Google Drive, Funny or Die, CollegeHumor, MPORA, Wistia, Youku, and Rutube.
|
6 |
Author: Sutherland Boswell
|
7 |
Author URI: http://sutherlandboswell.com
|
8 |
+
Version: 2.4.1
|
9 |
License: GPL2
|
10 |
*/
|
11 |
/* Copyright 2014 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.4.1' );
|
32 |
|
33 |
// Providers
|
34 |
require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-video-thumbnails-providers.php' );
|
110 |
|
111 |
// Construct the meta box
|
112 |
function meta_box() {
|
113 |
+
global $post;
|
114 |
// Add hidden troubleshooting info
|
115 |
add_thickbox();
|
116 |
?>
|
128 |
</ol>
|
129 |
</div>
|
130 |
<?php
|
|
|
|
|
131 |
$custom = get_post_custom( $post->ID );
|
132 |
if ( isset( $custom[VIDEO_THUMBNAILS_FIELD][0] ) ) $video_thumbnail = $custom[VIDEO_THUMBNAILS_FIELD][0];
|
133 |
|
282 |
}
|
283 |
}
|
284 |
|
285 |
+
/**
|
286 |
+
* Creates a file name for use when saving an image to the media library.
|
287 |
+
* It will either use a sanitized version of the title or the post ID.
|
288 |
+
* @param int $post_id The ID of the post to create the filename for
|
289 |
+
* @return string A filename (without the extension)
|
290 |
+
*/
|
291 |
+
function construct_filename( $post_id ) {
|
292 |
+
$filename = get_the_title( $post_id );
|
293 |
+
$filename = sanitize_title( $filename, $post_id );
|
294 |
+
$filename = urldecode( $filename );
|
295 |
+
$filename = preg_replace( '/[^a-zA-Z0-9\-]/', '', $filename );
|
296 |
+
$filename = substr( $filename, 0, 32 );
|
297 |
+
$filename = trim( $filename, '-' );
|
298 |
+
if ( $filename == '' ) $filename = (string) $post_id;
|
299 |
+
return $filename;
|
300 |
+
}
|
301 |
+
|
302 |
// Saves to media library
|
303 |
public function save_to_media_library( $image_url, $post_id ) {
|
304 |
|
319 |
if ( $image_type == 'image/jpeg' ) $image_extension = '.jpg';
|
320 |
elseif ( $image_type == 'image/png' ) $image_extension = '.png';
|
321 |
|
322 |
+
// Construct a file name with extension
|
323 |
+
$new_filename = $this->construct_filename( $post_id ) . $image_extension;
|
324 |
|
325 |
// Save the image bits using the new filename
|
326 |
$upload = wp_upload_bits( $new_filename, null, $image_contents );
|