Version Description
- Added support for Vine
- Added support for Google Drive videos
- Rewritten bulk video thumbnail scanner
- Added troubleshooting link in meta box when no video thumbnail is found
- Changed provider test to compare file hashes in case thumbnail URLs change
Download this release
Release Info
Developer | sutherlandboswell |
Plugin | Video Thumbnails |
Version | 2.4 |
Comparing to | |
See all releases |
Code changes from version 2.3 to 2.4
- css/bulk.css +81 -0
- js/bulk.js +149 -0
- php/class-video-thumbnails-settings.php +24 -89
- php/providers/class-blip-thumbnails.php +12 -9
- php/providers/class-collegehumor-thumbnails.php +8 -6
- php/providers/class-dailymotion-thumbnails.php +8 -6
- php/providers/class-facebook-thumbnails.php +8 -6
- php/providers/class-funnyordie-thumbnails.php +8 -6
- php/providers/class-googledrive-thumbnails.php +101 -0
- php/providers/class-justintv-thumbnails.php +4 -3
- php/providers/class-kaltura-thumbnails.php +2 -2
- php/providers/class-metacafe-thumbnails.php +4 -3
- php/providers/class-mpora-thumbnails.php +8 -6
- php/providers/class-rutube-thumbnails.php +8 -6
- php/providers/class-twitch-thumbnails.php +8 -6
- php/providers/class-video-thumbnails-providers.php +3 -1
- php/providers/class-vimeo-thumbnails.php +24 -21
- php/providers/class-vine-thumbnails.php +77 -0
- php/providers/class-wistia-thumbnails.php +8 -6
- php/providers/class-youku-thumbnails.php +8 -6
- php/providers/class-youtube-thumbnails.php +16 -12
- readme.txt +24 -5
- video-thumbnails.php +123 -7
css/bulk.css
ADDED
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#vt-bulk-scan-results {
|
2 |
+
margin-top: 20px;
|
3 |
+
}
|
4 |
+
|
5 |
+
#vt-bulk-scan-results .progress-bar-container {
|
6 |
+
position: relative;
|
7 |
+
height: 30px;
|
8 |
+
background-color: #ddd;
|
9 |
+
width: 100%;
|
10 |
+
border-radius: 5px;
|
11 |
+
overflow: hidden;
|
12 |
+
}
|
13 |
+
|
14 |
+
#vt-bulk-scan-results .percentage {
|
15 |
+
display: block;
|
16 |
+
position: absolute;
|
17 |
+
line-height: 20px;
|
18 |
+
top: 5px;
|
19 |
+
width: 100%;
|
20 |
+
font-weight: bold;
|
21 |
+
text-align: center;
|
22 |
+
text-shadow: 0 -1px 0 rgba(255,255,255,.3);
|
23 |
+
}
|
24 |
+
|
25 |
+
#vt-bulk-scan-results .progress-bar {
|
26 |
+
display: none;
|
27 |
+
box-sizing: border-box;
|
28 |
+
background-color: #739c21;
|
29 |
+
height: 30px;
|
30 |
+
background-image: -webkit-gradient(linear,left top,left bottom,from(#91c429),to(#739c21));
|
31 |
+
background-image: -webkit-linear-gradient(top,#91c429,#739c21);
|
32 |
+
background-image: -moz-linear-gradient(top,#91c429,#739c21);
|
33 |
+
background-image: -ms-linear-gradient(top,#91c429,#739c21);
|
34 |
+
background-image: -o-linear-gradient(top,#91c429,#739c21);
|
35 |
+
background-image: linear-gradient(to bottom,#91c429,#739c21);
|
36 |
+
border-width: 1px;
|
37 |
+
border-style: solid;
|
38 |
+
border-color: #739c21;
|
39 |
+
border-bottom-color: #678c1d;
|
40 |
+
-webkit-box-shadow: inset 0 1px 0 rgba(193,229,119,.5);
|
41 |
+
box-shadow: inset 0 1px 0 rgba(193,229,119,.5);
|
42 |
+
width: 0;
|
43 |
+
background-position: initial initial;
|
44 |
+
background-repeat: initial initial;
|
45 |
+
border-radius: 5px;
|
46 |
+
-webkit-transition: width 0.2s linear;
|
47 |
+
-moz-transition: width 0.2s linear;
|
48 |
+
transition: width 0.2s linear;
|
49 |
+
}
|
50 |
+
|
51 |
+
#vt-bulk-scan-results .progress-bar.disable-animation {
|
52 |
+
-webkit-transition: none;
|
53 |
+
-moz-transition: none;
|
54 |
+
transition: none;
|
55 |
+
}
|
56 |
+
|
57 |
+
#vt-bulk-scan-results .stats {
|
58 |
+
margin-top: 1em;
|
59 |
+
text-align: center;
|
60 |
+
}
|
61 |
+
|
62 |
+
#vt-bulk-scan-results .log {
|
63 |
+
overflow: auto;
|
64 |
+
height: 250px;
|
65 |
+
background: #eee;
|
66 |
+
border: 1px solid #ccc;
|
67 |
+
border-radius: 5px;
|
68 |
+
box-shadow: inset 0 0 4px #ccc;
|
69 |
+
}
|
70 |
+
|
71 |
+
#vt-bulk-scan-results .log li {
|
72 |
+
border-top: 1px solid #ccc;
|
73 |
+
padding: 10px;
|
74 |
+
margin-bottom: 0;
|
75 |
+
box-shadow: inset 0 1px 0 #fff;
|
76 |
+
}
|
77 |
+
|
78 |
+
#vt-bulk-scan-results .log li:first-child {
|
79 |
+
border-top: 0;
|
80 |
+
box-shadow: none;
|
81 |
+
}
|
js/bulk.js
ADDED
@@ -0,0 +1,149 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
jQuery(function ($) {
|
2 |
+
|
3 |
+
function VideoThumbnailsBulkScanner( posts ) {
|
4 |
+
this.currentItem = 0;
|
5 |
+
this.posts = posts;
|
6 |
+
this.paused = false;
|
7 |
+
this.newThumbnails = 0;
|
8 |
+
this.existingThumbnails = 0;
|
9 |
+
this.delay = 1000;
|
10 |
+
this.delayTimer = false;
|
11 |
+
this.logList = $('#vt-bulk-scan-results .log');
|
12 |
+
this.progressBar = $('#vt-bulk-scan-results .progress-bar');
|
13 |
+
}
|
14 |
+
|
15 |
+
VideoThumbnailsBulkScanner.prototype.log = function(text) {
|
16 |
+
$('<li>'+text+'</li>').prependTo(this.logList).hide().slideDown(200);
|
17 |
+
console.log(text);
|
18 |
+
};
|
19 |
+
|
20 |
+
VideoThumbnailsBulkScanner.prototype.startScan = function() {
|
21 |
+
this.paused = false;
|
22 |
+
if ( this.currentItem == 0 ) {
|
23 |
+
this.log( 'Started Scanning' );
|
24 |
+
this.progressBar.show();
|
25 |
+
this.resetProgressBar();
|
26 |
+
$('#video-thumbnails-scan-all-posts').parent().slideUp();
|
27 |
+
} else {
|
28 |
+
this.log( 'Resumed Scanning' );
|
29 |
+
}
|
30 |
+
this.scanCurrentItem();
|
31 |
+
};
|
32 |
+
|
33 |
+
VideoThumbnailsBulkScanner.prototype.pauseScan = function() {
|
34 |
+
this.clearSchedule();
|
35 |
+
this.paused = true;
|
36 |
+
this.log( 'Paused Scanning' );
|
37 |
+
};
|
38 |
+
|
39 |
+
VideoThumbnailsBulkScanner.prototype.toggleScan = function() {
|
40 |
+
if ( this.paused ) {
|
41 |
+
this.startScan();
|
42 |
+
} else {
|
43 |
+
this.pauseScan();
|
44 |
+
}
|
45 |
+
};
|
46 |
+
|
47 |
+
VideoThumbnailsBulkScanner.prototype.scanCompleted = function() {
|
48 |
+
this.log( 'Done! Scanned ' + this.posts.length + ' posts' );
|
49 |
+
};
|
50 |
+
|
51 |
+
VideoThumbnailsBulkScanner.prototype.resetProgressBar = function() {
|
52 |
+
$('#vt-bulk-scan-results .percentage').html('0%');
|
53 |
+
this.progressBar
|
54 |
+
.addClass('disable-animation')
|
55 |
+
.css('width','0')
|
56 |
+
this.progressBar.height();
|
57 |
+
this.progressBar.removeClass('disable-animation');
|
58 |
+
};
|
59 |
+
|
60 |
+
VideoThumbnailsBulkScanner.prototype.updateProgressBar = function() {
|
61 |
+
console.log( percentage = ( this.currentItem + 1 ) / this.posts.length );
|
62 |
+
if ( percentage == 1 ) {
|
63 |
+
progressText = 'Done!';
|
64 |
+
this.scanCompleted();
|
65 |
+
} else {
|
66 |
+
progressText = Math.round(percentage*100)+'%';
|
67 |
+
}
|
68 |
+
$('#vt-bulk-scan-results .percentage').html(progressText);
|
69 |
+
this.progressBar.css('width',(percentage*100)+'%');
|
70 |
+
};
|
71 |
+
|
72 |
+
VideoThumbnailsBulkScanner.prototype.updateCounter = function() {
|
73 |
+
$('#vt-bulk-scan-results .stats .scanned').html( 'Scanned ' + (this.currentItem+1) + ' of ' + this.posts.length );
|
74 |
+
$('#vt-bulk-scan-results .stats .found').html( 'Found ' + this.newThumbnails + ' new thumbnails and ' + this.existingThumbnails + ' existing thumbnails' );
|
75 |
+
}
|
76 |
+
|
77 |
+
VideoThumbnailsBulkScanner.prototype.updateStats = function() {
|
78 |
+
this.updateProgressBar();
|
79 |
+
this.updateCounter();
|
80 |
+
}
|
81 |
+
|
82 |
+
VideoThumbnailsBulkScanner.prototype.scheduleNextItem = function() {
|
83 |
+
if ( ( this.currentItem + 1 ) < this.posts.length ) {
|
84 |
+
var self = this;
|
85 |
+
self.currentItem++;
|
86 |
+
this.delayTimer = setTimeout(function() {
|
87 |
+
self.scanCurrentItem();
|
88 |
+
}, this.delay);
|
89 |
+
}
|
90 |
+
}
|
91 |
+
|
92 |
+
VideoThumbnailsBulkScanner.prototype.clearSchedule = function() {
|
93 |
+
clearTimeout( this.delayTimer );
|
94 |
+
}
|
95 |
+
|
96 |
+
VideoThumbnailsBulkScanner.prototype.scanCurrentItem = function() {
|
97 |
+
|
98 |
+
if ( this.paused ) return false;
|
99 |
+
|
100 |
+
if ( this.currentItem < this.posts.length ) {
|
101 |
+
|
102 |
+
this.log( '[' + this.posts[this.currentItem] + '] Scanning ' + (this.currentItem+1) + ' of ' + this.posts.length );
|
103 |
+
|
104 |
+
var data = {
|
105 |
+
action: 'video_thumbnails_get_thumbnail_for_post',
|
106 |
+
post_id: this.posts[this.currentItem]
|
107 |
+
};
|
108 |
+
var self = this;
|
109 |
+
$.post(ajaxurl, data, function(response) {
|
110 |
+
var result = $.parseJSON( response );
|
111 |
+
if ( result.length == 0 ) {
|
112 |
+
self.log( '[' + self.posts[self.currentItem] + '] No thumbnail' );
|
113 |
+
} else {
|
114 |
+
self.log( '[' + self.posts[self.currentItem] + '] ' + result.url + ' (' + result.type + ')' );
|
115 |
+
if ( result.type == 'new' ) {
|
116 |
+
self.newThumbnails++;
|
117 |
+
} else {
|
118 |
+
self.existingThumbnails++;
|
119 |
+
}
|
120 |
+
}
|
121 |
+
self.updateStats();
|
122 |
+
self.scheduleNextItem();
|
123 |
+
});
|
124 |
+
|
125 |
+
} else {
|
126 |
+
this.updateStats();
|
127 |
+
this.currentItem = 0;
|
128 |
+
}
|
129 |
+
|
130 |
+
};
|
131 |
+
|
132 |
+
$('#video-thumbnails-scan-all-posts').on('click',function(e){
|
133 |
+
e.preventDefault();
|
134 |
+
var data = {
|
135 |
+
action: 'video_thumbnails_bulk_posts_query'
|
136 |
+
};
|
137 |
+
$.post(ajaxurl, data, function(response) {
|
138 |
+
var posts = $.parseJSON( response );
|
139 |
+
var r = confirm("This will scan " + posts.length + " posts, continue?");
|
140 |
+
if ( r == true ) {
|
141 |
+
x = new VideoThumbnailsBulkScanner( posts );
|
142 |
+
x.startScan();
|
143 |
+
} else {
|
144 |
+
x = "You pressed Cancel!";
|
145 |
+
}
|
146 |
+
});
|
147 |
+
});
|
148 |
+
|
149 |
+
});
|
php/class-video-thumbnails-settings.php
CHANGED
@@ -37,9 +37,7 @@ class Video_Thumbnails_Settings {
|
|
37 |
add_action( 'admin_menu', array( &$this, 'admin_menu' ) );
|
38 |
// Initialize options
|
39 |
add_action( 'admin_init', array( &$this, 'initialize_options' ) );
|
40 |
-
// Ajax
|
41 |
-
add_action( 'wp_ajax_past_video_thumbnail', array( &$this, 'ajax_past_callback' ) );
|
42 |
-
// Ajax past search callback
|
43 |
add_action( 'wp_ajax_clear_all_video_thumbnails', array( &$this, 'ajax_clear_all_callback' ) );
|
44 |
// Ajax test callbacks
|
45 |
add_action( 'wp_ajax_video_thumbnail_provider_test', array( &$this, 'provider_test_callback' ) ); // Provider test
|
@@ -50,10 +48,6 @@ class Video_Thumbnails_Settings {
|
|
50 |
// Admin scripts
|
51 |
add_action( 'admin_enqueue_scripts', array( &$this, 'admin_scripts' ) );
|
52 |
}
|
53 |
-
// Ajax past posts script
|
54 |
-
if ( isset ( $_GET['page'] ) && ( $_GET['page'] == 'video_thumbnails' ) && isset ( $_GET['tab'] ) && ( $_GET['tab'] == 'mass_actions' ) ) {
|
55 |
-
add_action( 'admin_head', array( &$this, 'ajax_past_script' ) );
|
56 |
-
}
|
57 |
}
|
58 |
|
59 |
// Activation hook
|
@@ -141,81 +135,6 @@ class Video_Thumbnails_Settings {
|
|
141 |
wp_enqueue_script( 'video_thumbnails_clear', plugins_url( 'js/clear.js' , VIDEO_THUMBNAILS_PATH . '/video-thumbnails.php' ) );
|
142 |
}
|
143 |
|
144 |
-
function ajax_past_script() {
|
145 |
-
|
146 |
-
?><!-- Video Thumbnails Past Post Ajax -->
|
147 |
-
<script type="text/javascript">
|
148 |
-
function video_thumbnails_past(id) {
|
149 |
-
|
150 |
-
var data = {
|
151 |
-
action: 'past_video_thumbnail',
|
152 |
-
post_id: id
|
153 |
-
};
|
154 |
-
|
155 |
-
// since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
|
156 |
-
jQuery.post(ajaxurl, data, function(response){
|
157 |
-
|
158 |
-
document.getElementById(id+'_result').innerHTML = response;
|
159 |
-
|
160 |
-
});
|
161 |
-
|
162 |
-
};
|
163 |
-
<?php
|
164 |
-
$id_array = get_posts( array(
|
165 |
-
'showposts' => -1,
|
166 |
-
'post_type' => $this->options['post_types'],
|
167 |
-
'fields' => 'ids'
|
168 |
-
) );
|
169 |
-
$ids = implode( ', ', $id_array );
|
170 |
-
?>
|
171 |
-
|
172 |
-
var scanComplete = false;
|
173 |
-
|
174 |
-
function scan_video_thumbnails(){
|
175 |
-
|
176 |
-
if(scanComplete==false){
|
177 |
-
scanComplete = true;
|
178 |
-
var ids = new Array(<?php echo $ids; ?>);
|
179 |
-
for (var i = 0; i < ids.length; i++){
|
180 |
-
var container = document.getElementById('video-thumbnails-past');
|
181 |
-
var new_element = document.createElement('li');
|
182 |
-
new_element.setAttribute('id',ids[i]+'_result');
|
183 |
-
new_element.innerHTML = 'Waiting...';
|
184 |
-
container.insertBefore(new_element, container.firstChild);
|
185 |
-
}
|
186 |
-
for (var i = 0; i < ids.length; i++){
|
187 |
-
document.getElementById(ids[i]+'_result').innerHTML = '<span style="color:yellow">•</span> Working...';
|
188 |
-
video_thumbnails_past(ids[i]);
|
189 |
-
}
|
190 |
-
} else {
|
191 |
-
alert('Scan has already been run, please reload the page before trying again.')
|
192 |
-
}
|
193 |
-
|
194 |
-
}
|
195 |
-
</script><?php
|
196 |
-
|
197 |
-
}
|
198 |
-
|
199 |
-
function ajax_past_callback() {
|
200 |
-
global $wpdb; // this is how you get access to the database
|
201 |
-
|
202 |
-
$post_id = $_POST['post_id'];
|
203 |
-
|
204 |
-
echo get_the_title( $post_id ) . ' - ';
|
205 |
-
|
206 |
-
$video_thumbnail = get_video_thumbnail( $post_id );
|
207 |
-
|
208 |
-
if ( is_wp_error( $video_thumbnail ) ) {
|
209 |
-
echo $video_thumbnail->get_error_message();
|
210 |
-
} else if ( $video_thumbnail != null ) {
|
211 |
-
echo '<span style="color:green">✔</span> Success!';
|
212 |
-
} else {
|
213 |
-
echo '<span style="color:red">✖</span> Couldn\'t find a video thumbnail for this post.';
|
214 |
-
}
|
215 |
-
|
216 |
-
die();
|
217 |
-
}
|
218 |
-
|
219 |
function ajax_clear_all_callback() {
|
220 |
if ( wp_verify_nonce( $_POST['nonce'], 'clear_all_video_thumbnails' ) ) {
|
221 |
global $wpdb;
|
@@ -241,6 +160,16 @@ function scan_video_thumbnails(){
|
|
241 |
die();
|
242 |
}
|
243 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
244 |
function provider_test_callback() {
|
245 |
|
246 |
global $video_thumbnails;
|
@@ -273,14 +202,23 @@ function scan_video_thumbnails(){
|
|
273 |
} else {
|
274 |
$result = explode( '?', $result );
|
275 |
$result = $result[0];
|
276 |
-
|
|
|
|
|
277 |
echo '<td style="color:green;">✔ Passed</td>';
|
278 |
$passed++;
|
279 |
} else {
|
280 |
echo '<td style="color:red;">✗ Failed</td>';
|
281 |
$failed++;
|
282 |
}
|
283 |
-
echo '<td>'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
284 |
}
|
285 |
echo '</tr>';
|
286 |
}
|
@@ -366,7 +304,7 @@ function scan_video_thumbnails(){
|
|
366 |
register_setting( 'video_thumbnails', 'video_thumbnails', array( &$this, 'sanitize_callback' ) );
|
367 |
}
|
368 |
|
369 |
-
function sanitize_callback( $input ) {
|
370 |
$current_settings = get_option( 'video_thumbnails' );
|
371 |
$output = array();
|
372 |
// General settings
|
@@ -519,10 +457,7 @@ function scan_video_thumbnails(){
|
|
519 |
|
520 |
<p>Scan all of your past posts for video thumbnails. Be sure to save any settings before running the scan.</p>
|
521 |
|
522 |
-
<p><
|
523 |
-
|
524 |
-
<ol id="video-thumbnails-past">
|
525 |
-
</ol>
|
526 |
|
527 |
<h3>Clear all Video Thumbnails</h3>
|
528 |
|
37 |
add_action( 'admin_menu', array( &$this, 'admin_menu' ) );
|
38 |
// Initialize options
|
39 |
add_action( 'admin_init', array( &$this, 'initialize_options' ) );
|
40 |
+
// Ajax clear all callback
|
|
|
|
|
41 |
add_action( 'wp_ajax_clear_all_video_thumbnails', array( &$this, 'ajax_clear_all_callback' ) );
|
42 |
// Ajax test callbacks
|
43 |
add_action( 'wp_ajax_video_thumbnail_provider_test', array( &$this, 'provider_test_callback' ) ); // Provider test
|
48 |
// Admin scripts
|
49 |
add_action( 'admin_enqueue_scripts', array( &$this, 'admin_scripts' ) );
|
50 |
}
|
|
|
|
|
|
|
|
|
51 |
}
|
52 |
|
53 |
// Activation hook
|
135 |
wp_enqueue_script( 'video_thumbnails_clear', plugins_url( 'js/clear.js' , VIDEO_THUMBNAILS_PATH . '/video-thumbnails.php' ) );
|
136 |
}
|
137 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
138 |
function ajax_clear_all_callback() {
|
139 |
if ( wp_verify_nonce( $_POST['nonce'], 'clear_all_video_thumbnails' ) ) {
|
140 |
global $wpdb;
|
160 |
die();
|
161 |
}
|
162 |
|
163 |
+
function get_file_hash( $url ) {
|
164 |
+
$response = wp_remote_get( $url, array( 'sslverify' => false ) );
|
165 |
+
if( is_wp_error( $response ) ) {
|
166 |
+
$result = false;
|
167 |
+
} else {
|
168 |
+
$result = md5( $response['body'] );
|
169 |
+
}
|
170 |
+
return $result;
|
171 |
+
}
|
172 |
+
|
173 |
function provider_test_callback() {
|
174 |
|
175 |
global $video_thumbnails;
|
202 |
} else {
|
203 |
$result = explode( '?', $result );
|
204 |
$result = $result[0];
|
205 |
+
$result_hash = $this->get_file_hash( $result );
|
206 |
+
$matched = ( $result_hash == $test_case['expected_hash'] ? true : false );
|
207 |
+
if ( $matched ) {
|
208 |
echo '<td style="color:green;">✔ Passed</td>';
|
209 |
$passed++;
|
210 |
} else {
|
211 |
echo '<td style="color:red;">✗ Failed</td>';
|
212 |
$failed++;
|
213 |
}
|
214 |
+
echo '<td>';
|
215 |
+
if ( $result ) {
|
216 |
+
echo '<a href="' . $result . '">View Image</a>';
|
217 |
+
}
|
218 |
+
if ( $result_hash ) {
|
219 |
+
echo ' <code>' . $result_hash . '</code>';
|
220 |
+
}
|
221 |
+
echo '</td>';
|
222 |
}
|
223 |
echo '</tr>';
|
224 |
}
|
304 |
register_setting( 'video_thumbnails', 'video_thumbnails', array( &$this, 'sanitize_callback' ) );
|
305 |
}
|
306 |
|
307 |
+
function sanitize_callback( $input ) {
|
308 |
$current_settings = get_option( 'video_thumbnails' );
|
309 |
$output = array();
|
310 |
// General settings
|
457 |
|
458 |
<p>Scan all of your past posts for video thumbnails. Be sure to save any settings before running the scan.</p>
|
459 |
|
460 |
+
<p><a class="button-primary" href="<?php echo admin_url( 'tools.php?page=video-thumbnails-bulk' ); ?>">Scan Past Posts</a></p>
|
|
|
|
|
|
|
461 |
|
462 |
<h3>Clear all Video Thumbnails</h3>
|
463 |
|
php/providers/class-blip-thumbnails.php
CHANGED
@@ -58,19 +58,22 @@ class Blip_Thumbnails extends Video_Thumbnails_Providers {
|
|
58 |
// Test cases
|
59 |
public $test_cases = array(
|
60 |
array(
|
61 |
-
'markup'
|
62 |
-
'expected'
|
63 |
-
'
|
|
|
64 |
),
|
65 |
array(
|
66 |
-
'markup'
|
67 |
-
'expected'
|
68 |
-
'
|
|
|
69 |
),
|
70 |
array(
|
71 |
-
'markup'
|
72 |
-
'expected'
|
73 |
-
'
|
|
|
74 |
),
|
75 |
);
|
76 |
|
58 |
// Test cases
|
59 |
public $test_cases = array(
|
60 |
array(
|
61 |
+
'markup' => 'http://blip.tv/cranetv/illustrator-katie-scott-6617917',
|
62 |
+
'expected' => 'http://a.images.blip.tv/CraneTV-IllustratorKatieScott610.jpg',
|
63 |
+
'expected_hash' => '26a622f72bd4bdb3f8189f85598dd95d',
|
64 |
+
'name' => 'Video URL'
|
65 |
),
|
66 |
array(
|
67 |
+
'markup' => '<iframe src="http://blip.tv/play/AYL1uFkC.html?p=1" width="780" height="438" frameborder="0" allowfullscreen></iframe><embed type="application/x-shockwave-flash" src="http://a.blip.tv/api.swf#AYL1uFkC" style="display:none"></embed>',
|
68 |
+
'expected' => 'http://a.images.blip.tv/ReelScience-TheScientificMethodOfOz139.jpg',
|
69 |
+
'expected_hash' => 'bd2f58c2bc874e3a017167e74e5c842f',
|
70 |
+
'name' => 'iFrame player'
|
71 |
),
|
72 |
array(
|
73 |
+
'markup' => '<iframe src="http://blip.tv/play/AYLz%2BEsC.html?p=1" width="780" height="438" frameborder="0" allowfullscreen></iframe><embed type="application/x-shockwave-flash" src="http://a.blip.tv/api.swf#AYLz+EsC" style="display:none"></embed>',
|
74 |
+
'expected' => 'http://a.images.blip.tv/GeekCrashCourse-TheAvengersMarvelMovieCatchUpGeekCrashCourse331.png',
|
75 |
+
'expected_hash' => '87efa9f6b0d9111b0826ae4fbdddec1b',
|
76 |
+
'name' => 'iFrame player (special characters in ID)'
|
77 |
),
|
78 |
);
|
79 |
|
php/providers/class-collegehumor-thumbnails.php
CHANGED
@@ -54,14 +54,16 @@ class CollegeHumor_Thumbnails extends Video_Thumbnails_Providers {
|
|
54 |
// Test cases
|
55 |
public $test_cases = array(
|
56 |
array(
|
57 |
-
'markup'
|
58 |
-
'expected'
|
59 |
-
'
|
|
|
60 |
),
|
61 |
array(
|
62 |
-
'markup'
|
63 |
-
'expected'
|
64 |
-
'
|
|
|
65 |
),
|
66 |
);
|
67 |
|
54 |
// Test cases
|
55 |
public $test_cases = array(
|
56 |
array(
|
57 |
+
'markup' => '<iframe src="http://www.collegehumor.com/e/6830834" width="600" height="338" frameborder="0" webkitAllowFullScreen allowFullScreen></iframe><div style="padding:5px 0; text-align:center; width:600px;"><p><a href="http://www.collegehumor.com/videos/most-viewed/this-year">CollegeHumor\'s Favorite Funny Videos</a></p></div>',
|
58 |
+
'expected' => 'http://2.media.collegehumor.cvcdn.com/62/99/20502ca0d5b2172421002b52f437dcf8-mitt-romney-style-gangnam-style-parody.jpg',
|
59 |
+
'expected_hash' => 'ceac16f6ee1fa5d8707e813226060a15',
|
60 |
+
'name' => 'Embed'
|
61 |
),
|
62 |
array(
|
63 |
+
'markup' => 'http://www.collegehumor.com/video/6830834/mitt-romney-style-gangnam-style-parody',
|
64 |
+
'expected' => 'http://2.media.collegehumor.cvcdn.com/62/99/20502ca0d5b2172421002b52f437dcf8-mitt-romney-style-gangnam-style-parody.jpg',
|
65 |
+
'expected_hash' => 'ceac16f6ee1fa5d8707e813226060a15',
|
66 |
+
'name' => 'URL'
|
67 |
),
|
68 |
);
|
69 |
|
php/providers/class-dailymotion-thumbnails.php
CHANGED
@@ -56,14 +56,16 @@ class Dailymotion_Thumbnails extends Video_Thumbnails_Providers {
|
|
56 |
// Test cases
|
57 |
public $test_cases = array(
|
58 |
array(
|
59 |
-
'markup'
|
60 |
-
'expected'
|
61 |
-
'
|
|
|
62 |
),
|
63 |
array(
|
64 |
-
'markup'
|
65 |
-
'expected'
|
66 |
-
'
|
|
|
67 |
),
|
68 |
);
|
69 |
|
56 |
// Test cases
|
57 |
public $test_cases = array(
|
58 |
array(
|
59 |
+
'markup' => '<iframe frameborder="0" width="480" height="270" src="http://www.dailymotion.com/embed/video/xqlhts"></iframe><br /><a href="http://www.dailymotion.com/video/xqlhts_adam-yauch-of-the-beastie-boys-dies-at-47_people" target="_blank">Adam Yauch of the Beastie Boys Dies at 47</a> <i>by <a href="http://www.dailymotion.com/associatedpress" target="_blank">associatedpress</a></i>',
|
60 |
+
'expected' => 'http://s1.dmcdn.net/AMjdy.jpg',
|
61 |
+
'expected_hash' => '077888b97839254892a377f51c06e642',
|
62 |
+
'name' => 'iFrame player'
|
63 |
),
|
64 |
array(
|
65 |
+
'markup' => '<object width="480" height="270"><param name="movie" value="http://www.dailymotion.com/swf/video/xqlhts"></param><param name="allowFullScreen" value="true"></param><param name="allowScriptAccess" value="always"></param><param name="wmode" value="transparent"></param><embed type="application/x-shockwave-flash" src="http://www.dailymotion.com/swf/video/xqlhts" width="480" height="270" wmode="transparent" allowfullscreen="true" allowscriptaccess="always"></embed></object><br /><a href="http://www.dailymotion.com/video/xqlhts_adam-yauch-of-the-beastie-boys-dies-at-47_people" target="_blank">Adam Yauch of the Beastie Boys Dies at 47</a> <i>by <a href="http://www.dailymotion.com/associatedpress" target="_blank">associatedpress</a></i>',
|
66 |
+
'expected' => 'http://s1.dmcdn.net/AMjdy.jpg',
|
67 |
+
'expected_hash' => '077888b97839254892a377f51c06e642',
|
68 |
+
'name' => 'Flash player'
|
69 |
),
|
70 |
);
|
71 |
|
php/providers/class-facebook-thumbnails.php
CHANGED
@@ -47,14 +47,16 @@ class Facebook_Thumbnails extends Video_Thumbnails_Providers {
|
|
47 |
// Test cases
|
48 |
public $test_cases = array(
|
49 |
array(
|
50 |
-
'markup'
|
51 |
-
'expected'
|
52 |
-
'
|
|
|
53 |
),
|
54 |
array(
|
55 |
-
'markup'
|
56 |
-
'expected'
|
57 |
-
'
|
|
|
58 |
),
|
59 |
);
|
60 |
|
47 |
// Test cases
|
48 |
public $test_cases = array(
|
49 |
array(
|
50 |
+
'markup' => '<object width=420 height=180><param name=allowfullscreen value=true></param><param name=allowscriptaccess value=always></param><param name=movie value="http://www.facebook.com/v/2560032632599"></param><embed src="http://www.facebook.com/v/2560032632599" type="application/x-shockwave-flash" allowscriptaccess=always allowfullscreen=true width=420 height=180></embed></object>',
|
51 |
+
'expected' => 'https://graph.facebook.com/2560032632599/picture',
|
52 |
+
'expected_hash' => '619591ec126ad889799ad992a227c75e',
|
53 |
+
'name' => 'Flash Embed'
|
54 |
),
|
55 |
array(
|
56 |
+
'markup' => '<iframe src="https://www.facebook.com/video/embed?video_id=2560032632599" width="960" height="720" frameborder="0"></iframe>',
|
57 |
+
'expected' => 'https://graph.facebook.com/2560032632599/picture',
|
58 |
+
'expected_hash' => '619591ec126ad889799ad992a227c75e',
|
59 |
+
'name' => 'iFrame Embed'
|
60 |
),
|
61 |
);
|
62 |
|
php/providers/class-funnyordie-thumbnails.php
CHANGED
@@ -55,14 +55,16 @@ class Funnyordie_Thumbnails extends Video_Thumbnails_Providers {
|
|
55 |
// Test cases
|
56 |
public $test_cases = array(
|
57 |
array(
|
58 |
-
'markup'
|
59 |
-
'expected'
|
60 |
-
'
|
|
|
61 |
),
|
62 |
array(
|
63 |
-
'markup'
|
64 |
-
'expected'
|
65 |
-
'
|
|
|
66 |
),
|
67 |
);
|
68 |
|
55 |
// Test cases
|
56 |
public $test_cases = array(
|
57 |
array(
|
58 |
+
'markup' => '<iframe src="http://www.funnyordie.com/embed/5325b03b52" width="640" height="400" frameborder="0"></iframe>',
|
59 |
+
'expected' => 'http://t.fod4.com/t/5325b03b52/c480x270_17.jpg',
|
60 |
+
'expected_hash' => '5aafa4a5f27bd4aead574db38a9e8b2b',
|
61 |
+
'name' => 'iFrame player'
|
62 |
),
|
63 |
array(
|
64 |
+
'markup' => '<object width="640" height="400" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" id="ordie_player_5325b03b52"><param name="movie" value="http://player.ordienetworks.com/flash/fodplayer.swf" /><param name="flashvars" value="key=5325b03b52" /><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always"><embed width="640" height="400" flashvars="key=5325b03b52" allowfullscreen="true" allowscriptaccess="always" quality="high" src="http://player.ordienetworks.com/flash/fodplayer.swf" name="ordie_player_5325b03b52" type="application/x-shockwave-flash"></embed></object>',
|
65 |
+
'expected' => 'http://t.fod4.com/t/5325b03b52/c480x270_17.jpg',
|
66 |
+
'expected_hash' => '5aafa4a5f27bd4aead574db38a9e8b2b',
|
67 |
+
'name' => 'Flash player'
|
68 |
),
|
69 |
);
|
70 |
|
php/providers/class-googledrive-thumbnails.php
ADDED
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/* Copyright 2014 Sutherland Boswell (email : sutherland.boswell@gmail.com)
|
4 |
+
|
5 |
+
This program is free software; you can redistribute it and/or modify
|
6 |
+
it under the terms of the GNU General Public License, version 2, as
|
7 |
+
published by the Free Software Foundation.
|
8 |
+
|
9 |
+
This program is distributed in the hope that it will be useful,
|
10 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12 |
+
GNU General Public License for more details.
|
13 |
+
|
14 |
+
You should have received a copy of the GNU General Public License
|
15 |
+
along with this program; if not, write to the Free Software
|
16 |
+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
17 |
+
*/
|
18 |
+
|
19 |
+
// Require thumbnail provider class
|
20 |
+
require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-video-thumbnails-providers.php' );
|
21 |
+
|
22 |
+
class GoogleDrive_Thumbnails extends Video_Thumbnails_Providers {
|
23 |
+
|
24 |
+
// Human-readable name of the video provider
|
25 |
+
public $service_name = 'Google Drive';
|
26 |
+
const service_name = 'Google Drive';
|
27 |
+
// Slug for the video provider
|
28 |
+
public $service_slug = 'googledrive';
|
29 |
+
const service_slug = 'googledrive';
|
30 |
+
|
31 |
+
public $options_section = array(
|
32 |
+
'description' => '<p><strong>Optional</strong>: Only required if using videos from Google Drive.</p><p><strong>Directions</strong>: Go to the <a href="https://cloud.google.com/console/project">Google Developers Console</a>, create a project, then enable the Drive API. Next go to the credentials section and create a new public API access key. Choose server key, then leave allowed IPs blank and click create. Copy and paste your new API key below.</p>',
|
33 |
+
'fields' => array(
|
34 |
+
'api_key' => array(
|
35 |
+
'name' => 'API Key',
|
36 |
+
'type' => 'text',
|
37 |
+
'description' => ''
|
38 |
+
)
|
39 |
+
)
|
40 |
+
);
|
41 |
+
|
42 |
+
public static function register_provider( $providers ) {
|
43 |
+
$providers[self::service_slug] = new self;
|
44 |
+
return $providers;
|
45 |
+
}
|
46 |
+
|
47 |
+
// Regex strings
|
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
|
54 |
+
public function get_thumbnail_url( $id ) {
|
55 |
+
// Get our API key
|
56 |
+
$api_key = ( isset( $this->options['api_key'] ) && $this->options['api_key'] != '' ? $this->options['api_key'] : false );
|
57 |
+
|
58 |
+
if ( $api_key ) {
|
59 |
+
$request = "https://www.googleapis.com/drive/v2/files/$id?fields=thumbnailLink&key=$api_key";
|
60 |
+
$response = wp_remote_get( $request, array( 'sslverify' => false ) );
|
61 |
+
if( is_wp_error( $response ) ) {
|
62 |
+
$result = new WP_Error( 'googledrive_info_retrieval', __( 'Error retrieving video information from the URL <a href="' . $request . '">' . $request . '</a> using <code>wp_remote_get()</code><br />If opening that URL in your web browser returns anything else than an error page, the problem may be related to your web server and might be something your host administrator can solve.<br />Details: ' . $response->get_error_message() ) );
|
63 |
+
} else {
|
64 |
+
$json = json_decode( $response['body'] );
|
65 |
+
$result = $json->thumbnailLink;
|
66 |
+
$result = str_replace( '=s220', '=s480', $result );
|
67 |
+
}
|
68 |
+
} else {
|
69 |
+
$result = new WP_Error( 'googledrive_api_key', __( 'You must enter an API key to retrieve thumbnails from Google Drive' ) );
|
70 |
+
}
|
71 |
+
return $result;
|
72 |
+
}
|
73 |
+
|
74 |
+
// Test cases
|
75 |
+
public $test_cases = array(
|
76 |
+
array(
|
77 |
+
'markup' => '<iframe src="https://docs.google.com/file/d/0B2tG5YeQL99ZUHNja3l6am9jSGM/preview?pli=1" width="640" height="385"></iframe>',
|
78 |
+
'expected' => 'https://lh3.googleusercontent.com/QL3d7Wh7V_qcXnMpXT6bio77RS0veyCZZ0zQbMX6gd-qH7aeIXBkXlcSJVDEyftiiA=s480',
|
79 |
+
'expected_hash' => '3bc674d8d77b342e633ab9e93e345462',
|
80 |
+
'name' => 'iFrame embed'
|
81 |
+
),
|
82 |
+
array(
|
83 |
+
'markup' => '<iframe height="385" src="https://docs.google.com/a/svpanthers.org/file/d/0BxQsabDaO6USYUgxSUJ3T0ZBa3M/preview" width="100%"></iframe>',
|
84 |
+
'expected' => 'https://lh6.googleusercontent.com/WeOdCsaplJ3am25To1uLZiVYkyrilAQ5rxzhjnyyFc5GAF4QeCF1eq3EMpbP7O5dFg=s480',
|
85 |
+
'expected_hash' => 'f120755bbd1d35e381cb84a829ac0dfa',
|
86 |
+
'name' => 'iFrame embed (Apps account)'
|
87 |
+
),
|
88 |
+
array(
|
89 |
+
'markup' => '<object width="500" height="385" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowScriptAccess" value="always" /><param name="src" value="https://video.google.com/get_player?docid=0B92WKFCDHyg9NTRqYTFjVkZmNlk&ps=docs&partnerid=30&cc_load_policy=1" /><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><embed width="500" height="385" type="application/x-shockwave-flash" src="https://video.google.com/get_player?docid=0B92WKFCDHyg9NTRqYTFjVkZmNlk&ps=docs&partnerid=30&cc_load_policy=1" allowFullScreen="true" allowScriptAccess="always" allowfullscreen="true" allowscriptaccess="always" /></object>',
|
90 |
+
'expected' => 'https://lh3.googleusercontent.com/U_lqaX1o7E9iU75XwCrHZ4pdSi-Vch2F_GK5Ib7WAxgwKTvTl0kMHXm2GxKo1Pcp3Q=s480',
|
91 |
+
'expected_hash' => '31cf8e05f981c1beb6e04823ad54d267',
|
92 |
+
'name' => 'Flash embed'
|
93 |
+
),
|
94 |
+
);
|
95 |
+
|
96 |
+
}
|
97 |
+
|
98 |
+
// Add to provider array
|
99 |
+
add_filter( 'video_thumbnail_providers', array( 'GoogleDrive_Thumbnails', 'register_provider' ) );
|
100 |
+
|
101 |
+
?>
|
php/providers/class-justintv-thumbnails.php
CHANGED
@@ -54,9 +54,10 @@ class Justintv_Thumbnails extends Video_Thumbnails_Providers {
|
|
54 |
// Test cases
|
55 |
public $test_cases = array(
|
56 |
array(
|
57 |
-
'markup'
|
58 |
-
'expected'
|
59 |
-
'
|
|
|
60 |
),
|
61 |
);
|
62 |
|
54 |
// Test cases
|
55 |
public $test_cases = array(
|
56 |
array(
|
57 |
+
'markup' => '<object type="application/x-shockwave-flash" height="300" width="400" id="clip_embed_player_flash" data="http://www-cdn.justin.tv/widgets/archive_embed_player.swf" bgcolor="#000000"><param name="movie" value="http://www-cdn.justin.tv/widgets/archive_embed_player.swf" /><param name="allowScriptAccess" value="always" /><param name="allowNetworking" value="all" /><param name="allowFullScreen" value="true" /><param name="flashvars" value="auto_play=false&start_volume=25&title=Title&channel=scamschoolbrian&archive_id=392481524" /></object>',
|
58 |
+
'expected' => 'http://static-cdn.jtvnw.net/jtv.thumbs/archive-392481524-320x240.jpg',
|
59 |
+
'expected_hash' => '7f260a2ce6ae75a3c2e5012108f161b7',
|
60 |
+
'name' => 'Embed'
|
61 |
),
|
62 |
);
|
63 |
|
php/providers/class-kaltura-thumbnails.php
CHANGED
@@ -62,9 +62,9 @@ class Kaltura_Thumbnails extends Video_Thumbnails_Providers {
|
|
62 |
// Test cases
|
63 |
public $test_cases = array(
|
64 |
array(
|
65 |
-
'markup'
|
66 |
'expected' => 'http://example.com/thumbnail.jpg',
|
67 |
-
'name'
|
68 |
),
|
69 |
);
|
70 |
|
62 |
// Test cases
|
63 |
public $test_cases = array(
|
64 |
array(
|
65 |
+
'markup' => '<script type="text/javascript" src="http://cdnapi.kaltura.com/p/1374841/sp/137484100/embedIframeJs/uiconf_id/12680902/partner_id/1374841?entry_id=1_y7xzqsxw&playerId=kaltura_player_1363589321&cache_st=1363589321&autoembed=true&width=400&height=333&"></script>',
|
66 |
'expected' => 'http://example.com/thumbnail.jpg',
|
67 |
+
'name' => 'Auto embed'
|
68 |
),
|
69 |
);
|
70 |
|
php/providers/class-metacafe-thumbnails.php
CHANGED
@@ -55,9 +55,10 @@ class Metacafe_Thumbnails extends Video_Thumbnails_Providers {
|
|
55 |
// Test cases
|
56 |
public $test_cases = array(
|
57 |
array(
|
58 |
-
'markup'
|
59 |
-
'expected'
|
60 |
-
'
|
|
|
61 |
),
|
62 |
);
|
63 |
|
55 |
// Test cases
|
56 |
public $test_cases = array(
|
57 |
array(
|
58 |
+
'markup' => '<embed flashVars="playerVars=autoPlay=no" src="http://www.metacafe.com/fplayer/8456223/men_in_black_3_trailer_2.swf" width="440" height="248" wmode="transparent" allowFullScreen="true" allowScriptAccess="always" name="Metacafe_8456223" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed>',
|
59 |
+
'expected' => 'http://s4.mcstatic.com/thumb/8456223/22479418/4/catalog_item5/0/1/men_in_black_3_trailer_2.jpg',
|
60 |
+
'expected_hash' => 'df46215fef1d9fb68eea64ba3ed9a4fd',
|
61 |
+
'name' => 'Embed'
|
62 |
),
|
63 |
);
|
64 |
|
php/providers/class-mpora-thumbnails.php
CHANGED
@@ -47,14 +47,16 @@ class Mpora_Thumbnails extends Video_Thumbnails_Providers {
|
|
47 |
// Test cases
|
48 |
public $test_cases = array(
|
49 |
array(
|
50 |
-
'markup'
|
51 |
-
'expected'
|
52 |
-
'
|
|
|
53 |
),
|
54 |
array(
|
55 |
-
'markup'
|
56 |
-
'expected'
|
57 |
-
'
|
|
|
58 |
),
|
59 |
);
|
60 |
}
|
47 |
// Test cases
|
48 |
public $test_cases = array(
|
49 |
array(
|
50 |
+
'markup' => '<object width="480" height="270" id="mporaplayer_wEr2CBooV_N" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" type="application/x-shockwave-flash" ><param name="movie" value="http://video.mpora.com/ep/wEr2CBooV/"></param><param name="wmode" value="transparent"></param><param name="allowScriptAccess" value="always"></param><param name="allowFullScreen" value="true"></param><embed src="http://video.mpora.com/ep/wEr2CBooV/" width="480" height="270" wmode="transparent" allowfullscreen="true" allowscriptaccess="always" type="application/x-shockwave-flash"></embed></object>',
|
51 |
+
'expected' => 'http://ugc4.mporatrons.com/thumbs/wEr2CBooV_640x360_0000.jpg',
|
52 |
+
'expected_hash' => '95075bd4941251ebecbab3b436a90c49',
|
53 |
+
'name' => 'Flash player'
|
54 |
),
|
55 |
array(
|
56 |
+
'markup' => '<iframe width="640" height="360" src="http://mpora.com/videos/AAdfegovdop0/embed" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>',
|
57 |
+
'expected' => 'http://ugc4.mporatrons.com/thumbs/AAdfegovdop0_640x360_0000.jpg',
|
58 |
+
'expected_hash' => '45db22a2ba5ef20163f52ba562b89259',
|
59 |
+
'name' => 'iFrame player'
|
60 |
),
|
61 |
);
|
62 |
}
|
php/providers/class-rutube-thumbnails.php
CHANGED
@@ -55,14 +55,16 @@ class Rutube_Thumbnails extends Video_Thumbnails_Providers {
|
|
55 |
// Test cases
|
56 |
public $test_cases = array(
|
57 |
array(
|
58 |
-
'markup'
|
59 |
-
'expected'
|
60 |
-
'
|
|
|
61 |
),
|
62 |
array(
|
63 |
-
'markup'
|
64 |
-
'expected'
|
65 |
-
'
|
|
|
66 |
),
|
67 |
);
|
68 |
|
55 |
// Test cases
|
56 |
public $test_cases = array(
|
57 |
array(
|
58 |
+
'markup' => 'http://rutube.ru/video/ca8607cd4f7ef28516e043dde0068564/',
|
59 |
+
'expected' => 'http://pic.rutube.ru/video/3a/c8/3ac8c1ded16501002d20fa3ba3ed3d61.jpg',
|
60 |
+
'expected_hash' => '85ad79c118ee82c7c2a756ba29a96354',
|
61 |
+
'name' => 'Video link'
|
62 |
),
|
63 |
array(
|
64 |
+
'markup' => '<iframe width="720" height="405" src="//rutube.ru/video/embed/6608735" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowfullscreen></iframe>',
|
65 |
+
'expected' => 'http://pic.rutube.ru/video/3a/c8/3ac8c1ded16501002d20fa3ba3ed3d61.jpg',
|
66 |
+
'expected_hash' => '85ad79c118ee82c7c2a756ba29a96354',
|
67 |
+
'name' => 'iFrame embed'
|
68 |
),
|
69 |
);
|
70 |
|
php/providers/class-twitch-thumbnails.php
CHANGED
@@ -55,14 +55,16 @@ class Twitch_Thumbnails extends Video_Thumbnails_Providers {
|
|
55 |
// Test cases
|
56 |
public $test_cases = array(
|
57 |
array(
|
58 |
-
'markup'
|
59 |
-
'expected'
|
60 |
-
'
|
|
|
61 |
),
|
62 |
array(
|
63 |
-
'markup'
|
64 |
-
'expected'
|
65 |
-
'
|
|
|
66 |
),
|
67 |
);
|
68 |
|
55 |
// Test cases
|
56 |
public $test_cases = array(
|
57 |
array(
|
58 |
+
'markup' => 'http://www.twitch.tv/vanillatv/c/1537974',
|
59 |
+
'expected' => 'http://static-cdn.jtvnw.net/jtv.thumbs/archive-328087483-320x240.jpg',
|
60 |
+
'expected_hash' => 'f3921b65f799aa648ef6dae29871c137',
|
61 |
+
'name' => 'Video link'
|
62 |
),
|
63 |
array(
|
64 |
+
'markup' => '<object bgcolor="#000000" data="http://www.twitch.tv/widgets/archive_embed_player.swf" height="378" id="clip_embed_player_flash" type="application/x-shockwave-flash" width="620"><param name="movie" value="http://www.twitch.tv/widgets/archive_embed_player.swf"><param name="allowScriptAccess" value="always"><param name="allowNetworking" value="all"><param name="allowFullScreen" value="true"><param name="flashvars" value="title=VanillaTV%2B-%2BSweden%2Bvs%2BRussia%2B-%2BETF2L%2BNations%2BCup%2B-%2BSnakewater%2B%255BMap3%255D%2B-%2BPart%2B3&channel=vanillatv&auto_play=false&start_volume=25&chapter_id=1537974"></object>',
|
65 |
+
'expected' => 'http://static-cdn.jtvnw.net/jtv.thumbs/archive-328087483-320x240.jpg',
|
66 |
+
'expected_hash' => 'f3921b65f799aa648ef6dae29871c137',
|
67 |
+
'name' => 'Flash embed'
|
68 |
),
|
69 |
);
|
70 |
|
php/providers/class-video-thumbnails-providers.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
/* Copyright
|
4 |
|
5 |
This program is free software; you can redistribute it and/or modify
|
6 |
it under the terms of the GNU General Public License, version 2, as
|
@@ -92,6 +92,7 @@ class Video_Thumbnails_Providers {
|
|
92 |
require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-youtube-thumbnails.php' );
|
93 |
require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-vimeo-thumbnails.php' );
|
94 |
require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-facebook-thumbnails.php' );
|
|
|
95 |
require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-blip-thumbnails.php' );
|
96 |
require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-justintv-thumbnails.php' );
|
97 |
require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-dailymotion-thumbnails.php' );
|
@@ -104,5 +105,6 @@ require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-youku-thumbnails.php
|
|
104 |
require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-collegehumor-thumbnails.php' );
|
105 |
require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-rutube-thumbnails.php' );
|
106 |
require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-twitch-thumbnails.php' );
|
|
|
107 |
|
108 |
?>
|
1 |
<?php
|
2 |
|
3 |
+
/* Copyright 2014 Sutherland Boswell (email : sutherland.boswell@gmail.com)
|
4 |
|
5 |
This program is free software; you can redistribute it and/or modify
|
6 |
it under the terms of the GNU General Public License, version 2, as
|
92 |
require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-youtube-thumbnails.php' );
|
93 |
require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-vimeo-thumbnails.php' );
|
94 |
require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-facebook-thumbnails.php' );
|
95 |
+
require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-vine-thumbnails.php' );
|
96 |
require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-blip-thumbnails.php' );
|
97 |
require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-justintv-thumbnails.php' );
|
98 |
require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-dailymotion-thumbnails.php' );
|
105 |
require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-collegehumor-thumbnails.php' );
|
106 |
require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-rutube-thumbnails.php' );
|
107 |
require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-twitch-thumbnails.php' );
|
108 |
+
require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-googledrive-thumbnails.php' );
|
109 |
|
110 |
?>
|
php/providers/class-vimeo-thumbnails.php
CHANGED
@@ -61,22 +61,22 @@ class Vimeo_Thumbnails extends Video_Thumbnails_Providers {
|
|
61 |
|
62 |
// Regex strings
|
63 |
public $regexes = array(
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
);
|
72 |
|
73 |
// Thumbnail URL
|
74 |
public function get_thumbnail_url( $id ) {
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
// If API credentials are entered, use the API
|
81 |
if ( $client_id && $client_secret && $access_token && $access_token_secret ) {
|
82 |
$vimeo = new phpVimeo( $this->options['client_id'], $this->options['client_secret'] );
|
@@ -101,19 +101,22 @@ class Vimeo_Thumbnails extends Video_Thumbnails_Providers {
|
|
101 |
// Test cases
|
102 |
public $test_cases = array(
|
103 |
array(
|
104 |
-
'markup'
|
105 |
-
'expected'
|
106 |
-
'
|
|
|
107 |
),
|
108 |
array(
|
109 |
-
'markup'
|
110 |
-
'expected'
|
111 |
-
'
|
|
|
112 |
),
|
113 |
array(
|
114 |
-
'markup'
|
115 |
-
'expected'
|
116 |
-
'
|
|
|
117 |
),
|
118 |
);
|
119 |
|
61 |
|
62 |
// Regex strings
|
63 |
public $regexes = array(
|
64 |
+
'#<object[^>]+>.+?http://vimeo\.com/moogaloop.swf\?clip_id=([A-Za-z0-9\-_]+)&.+?</object>#s', // Standard Vimeo embed code
|
65 |
+
'#(?:https?:)?//player\.vimeo\.com/video/([0-9]+)#', // Vimeo iframe player
|
66 |
+
'#\[vimeo id=([A-Za-z0-9\-_]+)]#', // JR_embed shortcode
|
67 |
+
'#\[vimeo clip_id="([A-Za-z0-9\-_]+)"[^>]*]#', // Another shortcode
|
68 |
+
'#\[vimeo video_id="([A-Za-z0-9\-_]+)"[^>]*]#', // Yet another shortcode
|
69 |
+
'#(?:https?://)?(?:www\.)?vimeo\.com/([0-9]+)#', // Vimeo URL
|
70 |
+
'#(?:https?://)?(?:www\.)?vimeo\.com/channels/(?:[A-Za-z0-9]+)/([0-9]+)#' // Channel URL
|
71 |
);
|
72 |
|
73 |
// Thumbnail URL
|
74 |
public function get_thumbnail_url( $id ) {
|
75 |
+
// Get our settings
|
76 |
+
$client_id = ( isset( $this->options['client_id'] ) && $this->options['client_id'] != '' ? $this->options['client_id'] : false );
|
77 |
+
$client_secret = ( isset( $this->options['client_secret'] ) && $this->options['client_secret'] != '' ? $this->options['client_secret'] : false );
|
78 |
+
$access_token = ( isset( $this->options['access_token'] ) && $this->options['access_token'] != '' ? $this->options['access_token'] : false );
|
79 |
+
$access_token_secret = ( isset( $this->options['access_token_secret'] ) && $this->options['access_token_secret'] != '' ? $this->options['access_token_secret'] : false );
|
80 |
// If API credentials are entered, use the API
|
81 |
if ( $client_id && $client_secret && $access_token && $access_token_secret ) {
|
82 |
$vimeo = new phpVimeo( $this->options['client_id'], $this->options['client_secret'] );
|
101 |
// Test cases
|
102 |
public $test_cases = array(
|
103 |
array(
|
104 |
+
'markup' => '<iframe src="http://player.vimeo.com/video/41504360" width="500" height="281" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>',
|
105 |
+
'expected' => 'http://b.vimeocdn.com/ts/287/850/287850781_1280.jpg',
|
106 |
+
'expected_hash' => 'c60989d7ef599cfd07ec196c35a43623',
|
107 |
+
'name' => 'iFrame'
|
108 |
),
|
109 |
array(
|
110 |
+
'markup' => '<object width="500" height="281"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=41504360&force_embed=1&server=vimeo.com&show_title=1&show_byline=1&show_portrait=1&color=00adef&fullscreen=1&autoplay=0&loop=0" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=41504360&force_embed=1&server=vimeo.com&show_title=1&show_byline=1&show_portrait=1&color=00adef&fullscreen=1&autoplay=0&loop=0" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="500" height="281"></embed></object>',
|
111 |
+
'expected' => 'http://b.vimeocdn.com/ts/287/850/287850781_1280.jpg',
|
112 |
+
'expected_hash' => 'c60989d7ef599cfd07ec196c35a43623',
|
113 |
+
'name' => 'Old embed'
|
114 |
),
|
115 |
array(
|
116 |
+
'markup' => 'https://vimeo.com/channels/soundworkscollection/44520894',
|
117 |
+
'expected' => 'http://b.vimeocdn.com/ts/313/130/313130530_640.jpg',
|
118 |
+
'expected_hash' => 'e9fd72872a39272f6c540ee66b1ecf28',
|
119 |
+
'name' => 'Channel URL'
|
120 |
),
|
121 |
);
|
122 |
|
php/providers/class-vine-thumbnails.php
ADDED
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/* Copyright 2014 Sutherland Boswell (email : sutherland.boswell@gmail.com)
|
4 |
+
|
5 |
+
This program is free software; you can redistribute it and/or modify
|
6 |
+
it under the terms of the GNU General Public License, version 2, as
|
7 |
+
published by the Free Software Foundation.
|
8 |
+
|
9 |
+
This program is distributed in the hope that it will be useful,
|
10 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12 |
+
GNU General Public License for more details.
|
13 |
+
|
14 |
+
You should have received a copy of the GNU General Public License
|
15 |
+
along with this program; if not, write to the Free Software
|
16 |
+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
17 |
+
*/
|
18 |
+
|
19 |
+
// Require thumbnail provider class
|
20 |
+
require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-video-thumbnails-providers.php' );
|
21 |
+
|
22 |
+
class Vine_Thumbnails extends Video_Thumbnails_Providers {
|
23 |
+
|
24 |
+
// Human-readable name of the video provider
|
25 |
+
public $service_name = 'Vine';
|
26 |
+
const service_name = 'Vine';
|
27 |
+
// Slug for the video provider
|
28 |
+
public $service_slug = 'vine';
|
29 |
+
const service_slug = 'vine';
|
30 |
+
|
31 |
+
public static function register_provider( $providers ) {
|
32 |
+
$providers[self::service_slug] = new self;
|
33 |
+
return $providers;
|
34 |
+
}
|
35 |
+
|
36 |
+
// Regex strings
|
37 |
+
public $regexes = array(
|
38 |
+
'#(?:www\.)?vine\.co/v/([A-Za-z0-9_]+)#', // URL
|
39 |
+
);
|
40 |
+
|
41 |
+
// Thumbnail URL
|
42 |
+
public function get_thumbnail_url( $id ) {
|
43 |
+
$request = "https://vine.co/v/$id";
|
44 |
+
$response = wp_remote_get( $request, array( 'sslverify' => false ) );
|
45 |
+
if( is_wp_error( $response ) ) {
|
46 |
+
$result = new WP_Error( 'vine_info_retrieval', __( 'Error retrieving video information from the URL <a href="' . $request . '">' . $request . '</a> using <code>wp_remote_get()</code><br />If opening that URL in your web browser returns anything else than an error page, the problem may be related to your web server and might be something your host administrator can solve.<br />Details: ' . $response->get_error_message() ) );
|
47 |
+
} else {
|
48 |
+
$doc = new DOMDocument();
|
49 |
+
@$doc->loadHTML( $response['body'] );
|
50 |
+
$metas = $doc->getElementsByTagName( 'meta' );
|
51 |
+
for ( $i = 0; $i < $metas->length; $i++ ) {
|
52 |
+
$meta = $metas->item( $i );
|
53 |
+
if ( $meta->getAttribute( 'property' ) == 'og:image' ) {
|
54 |
+
$result = $meta->getAttribute( 'content' );
|
55 |
+
break;
|
56 |
+
}
|
57 |
+
}
|
58 |
+
}
|
59 |
+
return $result;
|
60 |
+
}
|
61 |
+
|
62 |
+
// Test cases
|
63 |
+
public $test_cases = array(
|
64 |
+
array(
|
65 |
+
'markup' => '<iframe class="vine-embed" src="https://vine.co/v/bpj7Km0T3d5/embed/simple" width="600" height="600" frameborder="0"></iframe><script async src="//platform.vine.co/static/scripts/embed.js" charset="utf-8"></script>',
|
66 |
+
'expected' => 'https://v.cdn.vine.co/v/thumbs/D6DDE013-F8DA-4929-9BED-49568F424343-184-00000008A20C1AEC_1.0.6.mp4.jpg',
|
67 |
+
'expected_hash' => '7cca5921108abe15b8c1c1f884a5b3ac',
|
68 |
+
'name' => 'Embed/Video URL'
|
69 |
+
),
|
70 |
+
);
|
71 |
+
|
72 |
+
}
|
73 |
+
|
74 |
+
// Add to provider array
|
75 |
+
add_filter( 'video_thumbnail_providers', array( 'Vine_Thumbnails', 'register_provider' ) );
|
76 |
+
|
77 |
+
?>
|
php/providers/class-wistia-thumbnails.php
CHANGED
@@ -78,14 +78,16 @@ class Wistia_Thumbnails extends Video_Thumbnails_Providers {
|
|
78 |
// Test cases
|
79 |
public $test_cases = array(
|
80 |
array(
|
81 |
-
'markup'
|
82 |
-
'expected'
|
83 |
-
'
|
|
|
84 |
),
|
85 |
array(
|
86 |
-
'markup'
|
87 |
-
'expected'
|
88 |
-
'
|
|
|
89 |
),
|
90 |
);
|
91 |
|
78 |
// Test cases
|
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' => 'http://embed-0.wistia.com/deliveries/6928fcba8355e38de4d95863a659e1de23cb2071.jpg',
|
83 |
+
'expected_hash' => 'bc4a2cec9ac97e2ccdae2c7387a01cb4',
|
84 |
+
'name' => 'Inline player'
|
85 |
),
|
86 |
array(
|
87 |
+
'markup' => '<div class=\'wistia_embed\' data-video-height=\'312\' data-video-width=\'499\' id=\'wistia_j1qd2lvys1\'></div> <script charset=\'ISO-8859-1\' src=\'http://fast.wistia.com/static/concat/E-v1.js\'></script> <script> var platform = ( Modernizr.touch ) ? "html5" : "flash"; wistiaEmbed = Wistia.embed("j1qd2lvys1", { version: "v1", videoWidth: 499, videoHeight: 312, playButton: Modernizr.touch, smallPlayButton: Modernizr.touch, playbar: Modernizr.touch, platformPreference: platform, chromeless: Modernizr.touch ? false : true, fullscreenButton: false, autoPlay: !Modernizr.touch, videoFoam: true }); </script>',
|
88 |
+
'expected' => 'https://embed-ssl.wistia.com/deliveries/a086707fe096e7f3fbefef1d1dcba1488d23a3e9.jpg',
|
89 |
+
'expected_hash' => '4c63d131604bfc07b5178413ab245813',
|
90 |
+
'name' => 'JavaScript API embedding'
|
91 |
),
|
92 |
);
|
93 |
|
php/providers/class-youku-thumbnails.php
CHANGED
@@ -55,14 +55,16 @@ class Youku_Thumbnails extends Video_Thumbnails_Providers {
|
|
55 |
// Test cases
|
56 |
public $test_cases = array(
|
57 |
array(
|
58 |
-
'markup'
|
59 |
-
'expected'
|
60 |
-
'
|
|
|
61 |
),
|
62 |
array(
|
63 |
-
'markup'
|
64 |
-
'expected'
|
65 |
-
'
|
|
|
66 |
),
|
67 |
);
|
68 |
|
55 |
// Test cases
|
56 |
public $test_cases = array(
|
57 |
array(
|
58 |
+
'markup' => '<embed src="http://player.youku.com/player.php/sid/XMzQyMzk5MzQ4/v.swf" quality="high" width="480" height="400" align="middle" allowScriptAccess="sameDomain" allowFullscreen="true" type="application/x-shockwave-flash"></embed>',
|
59 |
+
'expected' => 'http://g1.ykimg.com/1100641F464F0FB57407E2053DFCBC802FBBC4-E4C5-7A58-0394-26C366F10493',
|
60 |
+
'expected_hash' => 'deac7bb89058a8c46ae2350da9d33ba8',
|
61 |
+
'name' => 'Flash embed'
|
62 |
),
|
63 |
array(
|
64 |
+
'markup' => 'http://v.youku.com/v_show/id_XMzQyMzk5MzQ4.html',
|
65 |
+
'expected' => 'http://g1.ykimg.com/1100641F464F0FB57407E2053DFCBC802FBBC4-E4C5-7A58-0394-26C366F10493',
|
66 |
+
'expected_hash' => 'deac7bb89058a8c46ae2350da9d33ba8',
|
67 |
+
'name' => 'Link'
|
68 |
),
|
69 |
);
|
70 |
|
php/providers/class-youtube-thumbnails.php
CHANGED
@@ -56,24 +56,28 @@ class YouTube_Thumbnails extends Video_Thumbnails_Providers {
|
|
56 |
// Test cases
|
57 |
public $test_cases = array(
|
58 |
array(
|
59 |
-
'markup'
|
60 |
-
'expected'
|
61 |
-
'
|
|
|
62 |
),
|
63 |
array(
|
64 |
-
'markup'
|
65 |
-
'expected'
|
66 |
-
'
|
|
|
67 |
),
|
68 |
array(
|
69 |
-
'markup'
|
70 |
-
'expected'
|
71 |
-
'
|
|
|
72 |
),
|
73 |
array(
|
74 |
-
'markup'
|
75 |
-
'expected'
|
76 |
-
'
|
|
|
77 |
),
|
78 |
);
|
79 |
|
56 |
// Test cases
|
57 |
public $test_cases = array(
|
58 |
array(
|
59 |
+
'markup' => '<iframe width="560" height="315" src="http://www.youtube.com/embed/Fp0U2Vglkjw" frameborder="0" allowfullscreen></iframe>',
|
60 |
+
'expected' => 'http://img.youtube.com/vi/Fp0U2Vglkjw/maxresdefault.jpg',
|
61 |
+
'expected_hash' => 'c66256332969c38790c2b9f26f725e7a',
|
62 |
+
'name' => 'iFrame HD'
|
63 |
),
|
64 |
array(
|
65 |
+
'markup' => '<object width="560" height="315"><param name="movie" value="http://www.youtube.com/v/Fp0U2Vglkjw?version=3&hl=en_US"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/Fp0U2Vglkjw?version=3&hl=en_US" type="application/x-shockwave-flash" width="560" height="315" allowscriptaccess="always" allowfullscreen="true"></embed></object>',
|
66 |
+
'expected' => 'http://img.youtube.com/vi/Fp0U2Vglkjw/maxresdefault.jpg',
|
67 |
+
'expected_hash' => 'c66256332969c38790c2b9f26f725e7a',
|
68 |
+
'name' => 'Old embed HD'
|
69 |
),
|
70 |
array(
|
71 |
+
'markup' => '<iframe width="560" height="315" src="http://www.youtube.com/embed/vv_AitYPjtc" frameborder="0" allowfullscreen></iframe>',
|
72 |
+
'expected' => 'http://img.youtube.com/vi/vv_AitYPjtc/0.jpg',
|
73 |
+
'expected_hash' => '6c00b9ab335a6ea00b0fb964c39a6dc9',
|
74 |
+
'name' => 'iFrame SD'
|
75 |
),
|
76 |
array(
|
77 |
+
'markup' => '<object width="560" height="315"><param name="movie" value="http://www.youtube.com/v/vv_AitYPjtc?version=3&hl=en_US"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/vv_AitYPjtc?version=3&hl=en_US" type="application/x-shockwave-flash" width="560" height="315" allowscriptaccess="always" allowfullscreen="true"></embed></object>',
|
78 |
+
'expected' => 'http://img.youtube.com/vi/vv_AitYPjtc/0.jpg',
|
79 |
+
'expected_hash' => '6c00b9ab335a6ea00b0fb964c39a6dc9',
|
80 |
+
'name' => 'Old embed SD'
|
81 |
),
|
82 |
);
|
83 |
|
readme.txt
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
=== Video Thumbnails ===
|
2 |
Contributors: sutherlandboswell
|
3 |
Donate link: http://wie.ly/u/donate
|
4 |
-
Tags: Video, Thumbnails, YouTube, Vimeo,
|
5 |
Requires at least: 3.1
|
6 |
Tested up to: 3.8
|
7 |
-
Stable tag: 2.
|
8 |
|
9 |
Video Thumbnails simplifies the process of automatically displaying video thumbnails in your WordPress template.
|
10 |
|
@@ -17,17 +17,19 @@ Video Thumbnails currently supports these video services:
|
|
17 |
* YouTube
|
18 |
* Vimeo
|
19 |
* Facebook
|
20 |
-
*
|
21 |
* Justin.tv
|
|
|
22 |
* Dailymotion
|
23 |
* Metacafe
|
|
|
|
|
24 |
* Funny or Die
|
|
|
25 |
* MPORA
|
26 |
* Wistia
|
27 |
* Youku
|
28 |
-
* CollegeHumor
|
29 |
* Rutube
|
30 |
-
* Twitch
|
31 |
|
32 |
Video Thumbnails even works with most video embedding plugins, including:
|
33 |
|
@@ -50,6 +52,16 @@ Some functions are available to advanced users who want to customize their theme
|
|
50 |
|
51 |
== Frequently Asked Questions ==
|
52 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
= My theme isn't showing thumbnails, what's wrong? =
|
54 |
|
55 |
The most likely problem is that your theme doesn't support post thumbnails. If thumbnails are supported, you should see a box titled "Featured Image" on the edit post page. If thumbnails aren't supported, your theme will have to be modified to support Featured Images or to support one of our custom functions.
|
@@ -99,6 +111,13 @@ The Vimeo API has a rate limit, so in rare cases you may exceed this limit. Try
|
|
99 |
|
100 |
== Changelog ==
|
101 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
102 |
= 2.3 =
|
103 |
* Added support for archived Twitch videos
|
104 |
* Fixed issue with Funny or Die thumbnails
|
1 |
=== Video Thumbnails ===
|
2 |
Contributors: sutherlandboswell
|
3 |
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 |
|
17 |
* YouTube
|
18 |
* Vimeo
|
19 |
* Facebook
|
20 |
+
* Vine
|
21 |
* Justin.tv
|
22 |
+
* Twitch
|
23 |
* Dailymotion
|
24 |
* Metacafe
|
25 |
+
* Blip
|
26 |
+
* Google Drive
|
27 |
* Funny or Die
|
28 |
+
* CollegeHumor
|
29 |
* MPORA
|
30 |
* Wistia
|
31 |
* Youku
|
|
|
32 |
* Rutube
|
|
|
33 |
|
34 |
Video Thumbnails even works with most video embedding plugins, including:
|
35 |
|
52 |
|
53 |
== Frequently Asked Questions ==
|
54 |
|
55 |
+
= No video thumbnail for this post =
|
56 |
+
|
57 |
+
1. Ensure you have saved any changes to your post.
|
58 |
+
1. If you are using a a plugin or theme that stores videos in a special location other than the main post content area, be sure you've entered the correct custom field on the settings page. If you don't know the name of the field your video is being saved in, please contact the developer of that theme or plugin.
|
59 |
+
1. Copy and paste your embed code into the "Test Markup for Video" section of the Debugging page. If this doesn't find the thumbnail, you'll want to be sure to include the embed code you scanned when you request support. If it does find a thumbnail, please double check that you have the Custom Field set correctly in the settings page if you are using a a plugin or theme that stores videos in a special location.
|
60 |
+
1. Go to the Debugging page and click "Test Image Downloading" to test your server's ability to save an image from a video source.
|
61 |
+
1. Try posting a video from other sources to help narrow down the problem.
|
62 |
+
1. Check the support threads to see if anyone has had the same issue.
|
63 |
+
1. If you are still unable to resolve the problem, start a thread with a good descriptive title ("Error" or "No thumbnails" is a bad title) and be sure to include the results of your testing as well. Also be sure to include the name of your theme, any video plugins you're using, and any other details you can think of.
|
64 |
+
|
65 |
= My theme isn't showing thumbnails, what's wrong? =
|
66 |
|
67 |
The most likely problem is that your theme doesn't support post thumbnails. If thumbnails are supported, you should see a box titled "Featured Image" on the edit post page. If thumbnails aren't supported, your theme will have to be modified to support Featured Images or to support one of our custom functions.
|
111 |
|
112 |
== Changelog ==
|
113 |
|
114 |
+
= 2.4 =
|
115 |
+
* Added support for Vine
|
116 |
+
* Added support for Google Drive videos
|
117 |
+
* Rewritten bulk video thumbnail scanner
|
118 |
+
* Added troubleshooting link in meta box when no video thumbnail is found
|
119 |
+
* Changed provider test to compare file hashes in case thumbnail URLs change
|
120 |
+
|
121 |
= 2.3 =
|
122 |
* Added support for archived Twitch videos
|
123 |
* Fixed issue with Funny or Die thumbnails
|
video-thumbnails.php
CHANGED
@@ -2,13 +2,13 @@
|
|
2 |
/*
|
3 |
Plugin Name: Video Thumbnails
|
4 |
Plugin URI: http://refactored.co/plugins/video-thumbnails
|
5 |
-
Description: Automatically retrieve video thumbnails for your posts and display them in your theme.
|
6 |
Author: Sutherland Boswell
|
7 |
Author URI: http://sutherlandboswell.com
|
8 |
-
Version: 2.
|
9 |
License: GPL2
|
10 |
*/
|
11 |
-
/* Copyright
|
12 |
|
13 |
This program is free software; you can redistribute it and/or modify
|
14 |
it under the terms of the GNU General Public License, version 2, as
|
@@ -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.
|
32 |
|
33 |
// Providers
|
34 |
require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-video-thumbnails-providers.php' );
|
@@ -71,6 +71,32 @@ class Video_Thumbnails {
|
|
71 |
// Add action for Ajax reset callback
|
72 |
add_action( 'wp_ajax_reset_video_thumbnail', array( &$this, 'ajax_reset_callback' ) );
|
73 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
}
|
75 |
|
76 |
// Initialize meta box on edit page
|
@@ -84,6 +110,25 @@ class Video_Thumbnails {
|
|
84 |
|
85 |
// Construct the meta box
|
86 |
function meta_box() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
87 |
global $post;
|
88 |
$custom = get_post_custom( $post->ID );
|
89 |
if ( isset( $custom[VIDEO_THUMBNAILS_FIELD][0] ) ) $video_thumbnail = $custom[VIDEO_THUMBNAILS_FIELD][0];
|
@@ -95,8 +140,8 @@ class Video_Thumbnails {
|
|
95 |
if ( isset( $video_thumbnail ) && $video_thumbnail != '' ) {
|
96 |
echo '<p><a href="#" id="video-thumbnails-reset" onclick="video_thumbnails_reset(\'' . $post->ID . '\' );return false;">Reset Video Thumbnail</a></p>';
|
97 |
} else {
|
98 |
-
echo '<p id="video-thumbnails-preview">
|
99 |
-
echo '<p><a href="#" id="video-thumbnails-reset" onclick="video_thumbnails_reset(\'' . $post->ID . '\' );return false;">Search Again</a
|
100 |
}
|
101 |
} else {
|
102 |
if ( isset( $video_thumbnail ) && $video_thumbnail != '' ) {
|
@@ -332,12 +377,83 @@ class Video_Thumbnails {
|
|
332 |
} else if ( $video_thumbnail != null ) {
|
333 |
echo '<img src="' . $video_thumbnail . '" style="max-width:100%;" />';
|
334 |
} else {
|
335 |
-
echo '
|
336 |
}
|
337 |
|
338 |
die();
|
339 |
}
|
340 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
341 |
}
|
342 |
|
343 |
$video_thumbnails = new Video_Thumbnails();
|
2 |
/*
|
3 |
Plugin Name: Video Thumbnails
|
4 |
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)
|
12 |
|
13 |
This program is free software; you can redistribute it and/or modify
|
14 |
it under the terms of the GNU General Public License, version 2, as
|
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' );
|
71 |
// Add action for Ajax reset callback
|
72 |
add_action( 'wp_ajax_reset_video_thumbnail', array( &$this, 'ajax_reset_callback' ) );
|
73 |
|
74 |
+
// Add admin menus
|
75 |
+
add_action( 'admin_menu', array( &$this, 'admin_menu' ) );
|
76 |
+
|
77 |
+
// Add JavaScript and CSS to admin pages
|
78 |
+
add_action( 'admin_enqueue_scripts', array( &$this, 'admin_scripts' ), 20 );
|
79 |
+
|
80 |
+
// Get the posts to be scanned in bulk
|
81 |
+
add_action('wp_ajax_video_thumbnails_bulk_posts_query', array( &$this, 'bulk_posts_query_callback' ) );
|
82 |
+
// Get the thumbnail for an individual post
|
83 |
+
add_action('wp_ajax_video_thumbnails_get_thumbnail_for_post', array( &$this, 'get_thumbnail_for_post_callback' ) );
|
84 |
+
|
85 |
+
}
|
86 |
+
|
87 |
+
/**
|
88 |
+
* Adds the admin menu items
|
89 |
+
*/
|
90 |
+
function admin_menu() {
|
91 |
+
add_management_page( 'Bulk Video Thumbnails', 'Bulk Video Thumbs', 'manage_options', 'video-thumbnails-bulk', array( &$this, 'bulk_scanning_page' ) );
|
92 |
+
}
|
93 |
+
|
94 |
+
function admin_scripts( $hook ) {
|
95 |
+
// Bulk tool page
|
96 |
+
if ( 'tools_page_video-thumbnails-bulk' == $hook ) {
|
97 |
+
wp_enqueue_script( 'video-thumbnails-bulk-js', plugins_url( '/js/bulk.js' , __FILE__ ), array( 'jquery' ), VIDEO_THUMBNAILS_VERSION );
|
98 |
+
wp_enqueue_style( 'video-thumbnails-bulk-css', plugins_url('/css/bulk.css', __FILE__), false, VIDEO_THUMBNAILS_VERSION );
|
99 |
+
}
|
100 |
}
|
101 |
|
102 |
// Initialize meta box on edit page
|
110 |
|
111 |
// Construct the meta box
|
112 |
function meta_box() {
|
113 |
+
|
114 |
+
// Add hidden troubleshooting info
|
115 |
+
add_thickbox();
|
116 |
+
?>
|
117 |
+
<div id="video-thumbnail-not-found-troubleshooting" style="display:none;">
|
118 |
+
<h2><?php _e( 'Troubleshooting Video Thumbnails' ); ?></h2>
|
119 |
+
<h3>No video thumbnail for this post</h3>
|
120 |
+
<ol>
|
121 |
+
<li>Ensure you have saved any changes to your post.</li>
|
122 |
+
<li>If you are using a a plugin or theme that stores videos in a special location other than the main post content area, be sure you've entered the correct custom field on the <a href="<?php echo admin_url( 'options-general.php?page=video_thumbnails' ); ?>">settings page</a>. If you don't know the name of the field your video is being saved in, please contact the developer of that theme or plugin.</li>
|
123 |
+
<li>Copy and paste your embed code into the "Test Markup for Video" section of the <a href="<?php echo admin_url( 'options-general.php?page=video_thumbnails&tab=debugging' ); ?>">Debugging page</a>. If this doesn't find the thumbnail, you'll want to be sure to include the embed code you scanned when you request support. If it does find a thumbnail, please double check that you have the Custom Field set correctly in the <a href="<?php echo admin_url( 'options-general.php?page=video_thumbnails' ); ?>">settings page</a> if you are using a a plugin or theme that stores videos in a special location.</li>
|
124 |
+
<li>Go to the <a href="<?php echo admin_url( 'options-general.php?page=video_thumbnails&tab=debugging' ); ?>">Debugging page</a> and click "Test Image Downloading" to test your server's ability to save an image from a video source.</li>
|
125 |
+
<li>Try posting a video from other sources to help narrow down the problem.</li>
|
126 |
+
<li>Check the <a href="http://wordpress.org/support/plugin/video-thumbnails">support threads</a> to see if anyone has had the same issue.</li>
|
127 |
+
<li>If you are still unable to resolve the problem, <a href="http://wordpress.org/support/plugin/video-thumbnails">start a thread</a> with a good descriptive title ("Error" or "No thumbnails" is a bad title) and be sure to include the results of your testing as well. Also be sure to include the name of your theme, any video plugins you're using, and any other details you can think of.</li>
|
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];
|
140 |
if ( isset( $video_thumbnail ) && $video_thumbnail != '' ) {
|
141 |
echo '<p><a href="#" id="video-thumbnails-reset" onclick="video_thumbnails_reset(\'' . $post->ID . '\' );return false;">Reset Video Thumbnail</a></p>';
|
142 |
} else {
|
143 |
+
echo '<p id="video-thumbnails-preview">No video thumbnail for this post.</p>';
|
144 |
+
echo '<p><a href="#" id="video-thumbnails-reset" onclick="video_thumbnails_reset(\'' . $post->ID . '\' );return false;">Search Again</a> <a href="#TB_inline?width=400&height=600&inlineId=video-thumbnail-not-found-troubleshooting" class="thickbox" style="float:right;">Troubleshoot<a/></p>';
|
145 |
}
|
146 |
} else {
|
147 |
if ( isset( $video_thumbnail ) && $video_thumbnail != '' ) {
|
377 |
} else if ( $video_thumbnail != null ) {
|
378 |
echo '<img src="' . $video_thumbnail . '" style="max-width:100%;" />';
|
379 |
} else {
|
380 |
+
echo 'No video thumbnail for this post.';
|
381 |
}
|
382 |
|
383 |
die();
|
384 |
}
|
385 |
|
386 |
+
function bulk_posts_query_callback() {
|
387 |
+
$args = array(
|
388 |
+
'showposts' => -1,
|
389 |
+
'post_type' => $this->settings->options['post_types'],
|
390 |
+
'fields' => 'ids'
|
391 |
+
);
|
392 |
+
$query = new WP_Query( $args );
|
393 |
+
echo json_encode( $query->posts );
|
394 |
+
die();
|
395 |
+
}
|
396 |
+
|
397 |
+
function get_thumbnail_for_post_callback() {
|
398 |
+
|
399 |
+
$post_id = $_POST['post_id'];
|
400 |
+
$thumb = get_post_meta( $post_id, VIDEO_THUMBNAILS_FIELD, true );
|
401 |
+
|
402 |
+
if ( $thumb == '' ) {
|
403 |
+
global $video_thumbnails;
|
404 |
+
$thumb = $video_thumbnails->get_video_thumbnail( $post_id );
|
405 |
+
if ( $thumb ) {
|
406 |
+
$type = 'new';
|
407 |
+
}
|
408 |
+
} else {
|
409 |
+
$type = 'existing';
|
410 |
+
}
|
411 |
+
|
412 |
+
if ( $thumb != '' ) {
|
413 |
+
$result = array(
|
414 |
+
'type' => $type,
|
415 |
+
'url' => $thumb
|
416 |
+
);
|
417 |
+
} else {
|
418 |
+
$result = array();
|
419 |
+
}
|
420 |
+
|
421 |
+
echo json_encode( $result );
|
422 |
+
die();
|
423 |
+
}
|
424 |
+
|
425 |
+
function bulk_scanning_page() {
|
426 |
+
|
427 |
+
if ( ! current_user_can( 'manage_options' ) ) {
|
428 |
+
wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
|
429 |
+
}
|
430 |
+
|
431 |
+
?>
|
432 |
+
<div class="wrap">
|
433 |
+
|
434 |
+
<div id="icon-tools" class="icon32"></div><h2>Bulk Video Thumbnail Generator</h2>
|
435 |
+
|
436 |
+
<p>Use this tool to scan all of your posts for Video Thumbnails.</p>
|
437 |
+
|
438 |
+
<p><a id="video-thumbnails-scan-all-posts" href="#" class="button button-primary">Scan All Posts</a></p>
|
439 |
+
|
440 |
+
<div id="vt-bulk-scan-results">
|
441 |
+
<div class="progress-bar-container">
|
442 |
+
<span class="percentage">0%</span>
|
443 |
+
<div class="progress-bar"> </div>
|
444 |
+
</div>
|
445 |
+
<div class="stats">
|
446 |
+
<div class="scanned"></div>
|
447 |
+
<div class="found"></div>
|
448 |
+
</div>
|
449 |
+
<ul class="log"></ul>
|
450 |
+
</div>
|
451 |
+
|
452 |
+
</div>
|
453 |
+
<?php
|
454 |
+
|
455 |
+
}
|
456 |
+
|
457 |
}
|
458 |
|
459 |
$video_thumbnails = new Video_Thumbnails();
|