Version Description
- Added feature to settings page that automatically detects the custom field
- Switched to JSON for Vimeo's oEmbed endpoint
- Added support for the "image/gif" MIME type
Download this release
Release Info
Developer | sutherlandboswell |
Plugin | Video Thumbnails |
Version | 2.6.2 |
Comparing to | |
See all releases |
Code changes from version 2.6.1 to 2.6.2
- js/clear.js +0 -16
- js/settings.js +58 -0
- js/test.js +0 -20
- php/class-video-thumbnails-settings.php +29 -3
- php/providers/class-vimeo-thumbnails.php +3 -3
- readme.txt +6 -1
- video-thumbnails.php +4 -2
js/clear.js
DELETED
@@ -1,16 +0,0 @@
|
|
1 |
-
function clear_all_video_thumbnails( nonce ) {
|
2 |
-
var confimation_result = confirm("Are you sure you want to clear all video thumbnails? This cannot be undone.");
|
3 |
-
if (confimation_result){
|
4 |
-
var data = {
|
5 |
-
action: 'clear_all_video_thumbnails',
|
6 |
-
nonce: nonce
|
7 |
-
};
|
8 |
-
document.getElementById( 'clear-all-video-thumbnails-result' ).innerHTML = '<p>Working...</p>';
|
9 |
-
jQuery.post(ajaxurl, data, function(response){
|
10 |
-
document.getElementById( 'clear-all-video-thumbnails-result' ).innerHTML = response;
|
11 |
-
});
|
12 |
-
}
|
13 |
-
else{
|
14 |
-
//
|
15 |
-
}
|
16 |
-
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
js/settings.js
ADDED
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// Custom field detection
|
2 |
+
jQuery(function ($) {
|
3 |
+
|
4 |
+
$('#vt_detect_custom_field').on('click',function(e) {
|
5 |
+
e.preventDefault();
|
6 |
+
var data = {
|
7 |
+
action: 'video_thumbnail_custom_field_detection'
|
8 |
+
};
|
9 |
+
$.post(ajaxurl, data, function(response){
|
10 |
+
if (response) {
|
11 |
+
$('#custom_field').val(response);
|
12 |
+
} else {
|
13 |
+
alert('We were unable to find a video in the custom fields of your most recently updated post.');
|
14 |
+
}
|
15 |
+
});
|
16 |
+
});
|
17 |
+
|
18 |
+
});
|
19 |
+
|
20 |
+
// Test actions
|
21 |
+
function test_video_thumbnail( test_type ) {
|
22 |
+
var data = {
|
23 |
+
action: 'video_thumbnail_' + test_type + '_test'
|
24 |
+
};
|
25 |
+
document.getElementById( test_type + '-test' ).innerHTML = 'Working...';
|
26 |
+
jQuery.post(ajaxurl, data, function(response){
|
27 |
+
document.getElementById( test_type + '-test' ).innerHTML = response;
|
28 |
+
});
|
29 |
+
};
|
30 |
+
|
31 |
+
function test_video_thumbnail_markup_detection() {
|
32 |
+
var data = {
|
33 |
+
action: 'video_thumbnail_markup_detection_test',
|
34 |
+
markup: jQuery('#markup-input').val()
|
35 |
+
};
|
36 |
+
document.getElementById( 'markup-test-result' ).innerHTML = '<p>Working...</p>';
|
37 |
+
jQuery.post(ajaxurl, data, function(response){
|
38 |
+
document.getElementById( 'markup-test-result' ).innerHTML = response;
|
39 |
+
});
|
40 |
+
}
|
41 |
+
|
42 |
+
// Clear all video thumbnails
|
43 |
+
function clear_all_video_thumbnails( nonce ) {
|
44 |
+
var confimation_result = confirm("Are you sure you want to clear all video thumbnails? This cannot be undone.");
|
45 |
+
if (confimation_result){
|
46 |
+
var data = {
|
47 |
+
action: 'clear_all_video_thumbnails',
|
48 |
+
nonce: nonce
|
49 |
+
};
|
50 |
+
document.getElementById( 'clear-all-video-thumbnails-result' ).innerHTML = '<p>Working...</p>';
|
51 |
+
jQuery.post(ajaxurl, data, function(response){
|
52 |
+
document.getElementById( 'clear-all-video-thumbnails-result' ).innerHTML = response;
|
53 |
+
});
|
54 |
+
}
|
55 |
+
else{
|
56 |
+
//
|
57 |
+
}
|
58 |
+
};
|
js/test.js
DELETED
@@ -1,20 +0,0 @@
|
|
1 |
-
function test_video_thumbnail( test_type ) {
|
2 |
-
var data = {
|
3 |
-
action: 'video_thumbnail_' + test_type + '_test'
|
4 |
-
};
|
5 |
-
document.getElementById( test_type + '-test' ).innerHTML = 'Working...';
|
6 |
-
jQuery.post(ajaxurl, data, function(response){
|
7 |
-
document.getElementById( test_type + '-test' ).innerHTML = response;
|
8 |
-
});
|
9 |
-
};
|
10 |
-
|
11 |
-
function test_video_thumbnail_markup_detection() {
|
12 |
-
var data = {
|
13 |
-
action: 'video_thumbnail_markup_detection_test',
|
14 |
-
markup: jQuery('#markup-input').val()
|
15 |
-
};
|
16 |
-
document.getElementById( 'markup-test-result' ).innerHTML = '<p>Working...</p>';
|
17 |
-
jQuery.post(ajaxurl, data, function(response){
|
18 |
-
document.getElementById( 'markup-test-result' ).innerHTML = response;
|
19 |
-
});
|
20 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
php/class-video-thumbnails-settings.php
CHANGED
@@ -37,6 +37,8 @@ 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 clear all callback
|
41 |
add_action( 'wp_ajax_clear_all_video_thumbnails', array( &$this, 'ajax_clear_all_callback' ) );
|
42 |
// Ajax test callbacks
|
@@ -133,8 +135,32 @@ class Video_Thumbnails_Settings {
|
|
133 |
}
|
134 |
|
135 |
function admin_scripts() {
|
136 |
-
wp_enqueue_script( '
|
137 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
138 |
}
|
139 |
|
140 |
function ajax_clear_all_callback() {
|
@@ -322,7 +348,7 @@ class Video_Thumbnails_Settings {
|
|
322 |
$this->add_text_setting(
|
323 |
'custom_field',
|
324 |
'Custom Field (optional)',
|
325 |
-
'Enter the name of the custom field where your embed code or video URL is stored.'
|
326 |
);
|
327 |
register_setting( 'video_thumbnails', 'video_thumbnails', array( &$this, 'sanitize_callback' ) );
|
328 |
}
|
37 |
add_action( 'admin_menu', array( &$this, 'admin_menu' ) );
|
38 |
// Initialize options
|
39 |
add_action( 'admin_init', array( &$this, 'initialize_options' ) );
|
40 |
+
// Custom field detection callback
|
41 |
+
add_action( 'wp_ajax_video_thumbnail_custom_field_detection', array( &$this, 'custom_field_detection_callback' ) );
|
42 |
// Ajax clear all callback
|
43 |
add_action( 'wp_ajax_clear_all_video_thumbnails', array( &$this, 'ajax_clear_all_callback' ) );
|
44 |
// Ajax test callbacks
|
135 |
}
|
136 |
|
137 |
function admin_scripts() {
|
138 |
+
wp_enqueue_script( 'video_thumbnails_settings', plugins_url( 'js/settings.js' , VIDEO_THUMBNAILS_PATH . '/video-thumbnails.php' ), array( 'jquery' ), VIDEO_THUMBNAILS_VERSION );
|
139 |
+
}
|
140 |
+
|
141 |
+
function custom_field_detection_callback() {
|
142 |
+
if ( current_user_can( 'manage_options' ) ) {
|
143 |
+
echo $this->detect_custom_field();
|
144 |
+
}
|
145 |
+
die();
|
146 |
+
}
|
147 |
+
|
148 |
+
function detect_custom_field() {
|
149 |
+
global $video_thumbnails;
|
150 |
+
$latest_post = get_posts( array(
|
151 |
+
'posts_per_page' => 1,
|
152 |
+
'post_type' => $this->options['post_types'],
|
153 |
+
'orderby' => 'modified',
|
154 |
+
) );
|
155 |
+
$latest_post = $latest_post[0];
|
156 |
+
$custom = get_post_meta( $latest_post->ID );
|
157 |
+
foreach ( $custom as $name => $values ) {
|
158 |
+
foreach ($values as $value) {
|
159 |
+
if ( $video_thumbnails->get_first_thumbnail_url( $value ) ) {
|
160 |
+
return $name;
|
161 |
+
}
|
162 |
+
}
|
163 |
+
}
|
164 |
}
|
165 |
|
166 |
function ajax_clear_all_callback() {
|
348 |
$this->add_text_setting(
|
349 |
'custom_field',
|
350 |
'Custom Field (optional)',
|
351 |
+
'<a href="#" class="button" id="vt_detect_custom_field">Automatically Detect</a> Enter the name of the custom field where your embed code or video URL is stored.'
|
352 |
);
|
353 |
register_setting( 'video_thumbnails', 'video_thumbnails', array( &$this, 'sanitize_callback' ) );
|
354 |
}
|
php/providers/class-vimeo-thumbnails.php
CHANGED
@@ -84,7 +84,7 @@ class Vimeo_Thumbnails extends Video_Thumbnails_Providers {
|
|
84 |
$response = $vimeo->call('vimeo.videos.getThumbnailUrls', array('video_id'=>$id));
|
85 |
$result = $response->thumbnails->thumbnail[count($response->thumbnails->thumbnail)-1]->_content;
|
86 |
} else {
|
87 |
-
$request = "http://vimeo.com/api/oembed.
|
88 |
$response = wp_remote_get( $request, array( 'sslverify' => false ) );
|
89 |
if( is_wp_error( $response ) ) {
|
90 |
$result = new WP_Error( 'vimeo_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() ) );
|
@@ -93,8 +93,8 @@ class Vimeo_Thumbnails extends Video_Thumbnails_Providers {
|
|
93 |
} elseif ( $response['response']['code'] == 403 ) {
|
94 |
$result = new WP_Error( 'vimeo_info_retrieval', __( 'The Vimeo endpoint located at <a href="' . $request . '">' . $request . '</a> returned a 403 error.<br />This can occur when a video has embedding disabled or restricted to certain domains. Try entering API credentials in the provider settings.' ) );
|
95 |
} else {
|
96 |
-
$
|
97 |
-
$result =
|
98 |
}
|
99 |
}
|
100 |
return $result;
|
84 |
$response = $vimeo->call('vimeo.videos.getThumbnailUrls', array('video_id'=>$id));
|
85 |
$result = $response->thumbnails->thumbnail[count($response->thumbnails->thumbnail)-1]->_content;
|
86 |
} else {
|
87 |
+
$request = "http://vimeo.com/api/oembed.json?url=http%3A//vimeo.com/$id";
|
88 |
$response = wp_remote_get( $request, array( 'sslverify' => false ) );
|
89 |
if( is_wp_error( $response ) ) {
|
90 |
$result = new WP_Error( 'vimeo_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() ) );
|
93 |
} elseif ( $response['response']['code'] == 403 ) {
|
94 |
$result = new WP_Error( 'vimeo_info_retrieval', __( 'The Vimeo endpoint located at <a href="' . $request . '">' . $request . '</a> returned a 403 error.<br />This can occur when a video has embedding disabled or restricted to certain domains. Try entering API credentials in the provider settings.' ) );
|
95 |
} else {
|
96 |
+
$result = json_decode( $response['body'] );
|
97 |
+
$result = $result->thumbnail_url;
|
98 |
}
|
99 |
}
|
100 |
return $result;
|
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.2
|
6 |
Tested up to: 3.8.1
|
7 |
-
Stable tag: 2.6.
|
8 |
|
9 |
Video Thumbnails simplifies the process of automatically displaying video thumbnails in your WordPress template.
|
10 |
|
@@ -118,6 +118,11 @@ The Vimeo API has a rate limit, so in rare cases you may exceed this limit. Try
|
|
118 |
|
119 |
== Changelog ==
|
120 |
|
|
|
|
|
|
|
|
|
|
|
121 |
= 2.6.1 =
|
122 |
* Fixed VK bug caused by IDs with a negative int
|
123 |
|
4 |
Tags: Video, Thumbnails, YouTube, Vimeo, Vine, Twitch, Dailymotion, Youku, Rutube, Featured Image
|
5 |
Requires at least: 3.2
|
6 |
Tested up to: 3.8.1
|
7 |
+
Stable tag: 2.6.2
|
8 |
|
9 |
Video Thumbnails simplifies the process of automatically displaying video thumbnails in your WordPress template.
|
10 |
|
118 |
|
119 |
== Changelog ==
|
120 |
|
121 |
+
= 2.6.2 =
|
122 |
+
* Added feature to settings page that automatically detects the custom field
|
123 |
+
* Switched to JSON for Vimeo's oEmbed endpoint
|
124 |
+
* Added support for the "image/gif" MIME type
|
125 |
+
|
126 |
= 2.6.1 =
|
127 |
* Fixed VK bug caused by IDs with a negative int
|
128 |
|
video-thumbnails.php
CHANGED
@@ -5,7 +5,7 @@ Plugin URI: https://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, VK, 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.6.
|
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.6.
|
32 |
|
33 |
// Providers
|
34 |
require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-video-thumbnails-providers.php' );
|
@@ -330,6 +330,8 @@ class Video_Thumbnails {
|
|
330 |
$image_extension = '.jpg';
|
331 |
} elseif ( $image_type == 'image/png' ) {
|
332 |
$image_extension = '.png';
|
|
|
|
|
333 |
} else {
|
334 |
return new WP_Error( 'thumbnail_upload', __( 'Unsupported MIME type:' ) . ' ' . $image_type );
|
335 |
}
|
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, VK, 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.6.2
|
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.6.2' );
|
32 |
|
33 |
// Providers
|
34 |
require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-video-thumbnails-providers.php' );
|
330 |
$image_extension = '.jpg';
|
331 |
} elseif ( $image_type == 'image/png' ) {
|
332 |
$image_extension = '.png';
|
333 |
+
} elseif ( $image_type == 'image/gif' ) {
|
334 |
+
$image_extension = '.gif';
|
335 |
} else {
|
336 |
return new WP_Error( 'thumbnail_upload', __( 'Unsupported MIME type:' ) . ' ' . $image_type );
|
337 |
}
|