Video Thumbnails - Version 2.2

Version Description

  • Added support for Rutube
Download this release

Release Info

Developer sutherlandboswell
Plugin Icon 128x128 Video Thumbnails
Version 2.2
Comparing to
See all releases

Code changes from version 2.1 to 2.2

php/providers/class-rutube-thumbnails.php ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Rutube_Thumbnails extends Video_Thumbnails_Providers {
23
+
24
+ // Human-readable name of the video provider
25
+ public $service_name = 'Rutube';
26
+ const service_name = 'Rutube';
27
+ // Slug for the video provider
28
+ public $service_slug = 'rutube';
29
+ const service_slug = 'rutube';
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
+ '#(?:https?://)?(?:www\.)?rutube\.ru/video/([A-Za-z0-9]+)#', // Video link
39
+ '#(?:https?:)?//rutube\.ru/video/embed/([0-9]+)#', // Embed src
40
+ );
41
+
42
+ // Thumbnail URL
43
+ public function get_thumbnail_url( $id ) {
44
+ $request = "http://rutube.ru/api/video/$id/?format=json";
45
+ $response = wp_remote_get( $request, array( 'sslverify' => false ) );
46
+ if( is_wp_error( $response ) ) {
47
+ $result = new WP_Error( 'rutube_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() ) );
48
+ } else {
49
+ $result = json_decode( $response['body'] );
50
+ $result = $result->thumbnail_url;
51
+ }
52
+ return $result;
53
+ }
54
+
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
+ 'name' => 'Video link'
61
+ ),
62
+ array(
63
+ 'markup' => '<iframe width="720" height="405" src="//rutube.ru/video/embed/6608735" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowfullscreen></iframe>',
64
+ 'expected' => 'http://pic.rutube.ru/video/3a/c8/3ac8c1ded16501002d20fa3ba3ed3d61.jpg',
65
+ 'name' => 'iFrame embed'
66
+ ),
67
+ );
68
+
69
+ }
70
+
71
+ // Add to provider array
72
+ add_filter( 'video_thumbnail_providers', array( 'Rutube_Thumbnails', 'register_provider' ) );
73
+
74
+ ?>
php/providers/class-video-thumbnails-providers.php CHANGED
@@ -102,5 +102,6 @@ require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-wistia-thumbnails.ph
102
  // require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-kaltura-thumbnails.php' );
103
  require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-youku-thumbnails.php' );
104
  require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-collegehumor-thumbnails.php' );
 
105
 
106
  ?>
102
  // require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-kaltura-thumbnails.php' );
103
  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
 
107
  ?>
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: sutherlandboswell
3
  Donate link: http://wie.ly/u/donate
4
  Tags: Video, Thumbnails, YouTube, Vimeo, Blip, Justin.tv, Dailymotion, Metacafe, Image, Featured Image, Post Thumbnail
5
  Requires at least: 3.1
6
- Tested up to: 3.7
7
- Stable tag: 2.1
8
 
9
  Video Thumbnails simplifies the process of automatically displaying video thumbnails in your WordPress template.
10
 
@@ -26,6 +26,7 @@ Video Thumbnails currently supports these video services:
26
  * Wistia
27
  * Youku
28
  * CollegeHumor
 
29
 
30
  Video Thumbnails even works with most video embedding plugins, including:
31
 
@@ -97,6 +98,9 @@ The Vimeo API has a rate limit, so in rare cases you may exceed this limit. Try
97
 
98
  == Changelog ==
99
 
 
 
 
100
  = 2.1 =
101
  * Changes under the hood to ensure the first video is found
102
  * Improved YouTube regex
3
  Donate link: http://wie.ly/u/donate
4
  Tags: Video, Thumbnails, YouTube, Vimeo, Blip, Justin.tv, Dailymotion, Metacafe, Image, Featured Image, Post Thumbnail
5
  Requires at least: 3.1
6
+ Tested up to: 3.8
7
+ Stable tag: 2.2
8
 
9
  Video Thumbnails simplifies the process of automatically displaying video thumbnails in your WordPress template.
10
 
26
  * Wistia
27
  * Youku
28
  * CollegeHumor
29
+ * Rutube
30
 
31
  Video Thumbnails even works with most video embedding plugins, including:
32
 
98
 
99
  == Changelog ==
100
 
101
+ = 2.2 =
102
+ * Added support for Rutube
103
+
104
  = 2.1 =
105
  * Changes under the hood to ensure the first video is found
106
  * Improved YouTube regex
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. Currently supports YouTube, Vimeo, Facebook, Blip.tv, Justin.tv, Dailymotion, Metacafe, Wistia, Youku, Funny or Die, and MPORA.
6
  Author: Sutherland Boswell
7
  Author URI: http://sutherlandboswell.com
8
- Version: 2.1
9
  License: GPL2
10
  */
11
  /* Copyright 2013 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.1' );
32
 
33
  // Providers
34
  require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-video-thumbnails-providers.php' );
@@ -342,6 +342,8 @@ class Video_Thumbnails {
342
 
343
  $video_thumbnails = new Video_Thumbnails();
344
 
 
 
345
  // End class
346
 
347
  // Get video thumbnail function
5
  Description: Automatically retrieve video thumbnails for your posts and display them in your theme. Currently supports YouTube, Vimeo, Facebook, Blip.tv, Justin.tv, Dailymotion, Metacafe, Wistia, Youku, Funny or Die, and MPORA.
6
  Author: Sutherland Boswell
7
  Author URI: http://sutherlandboswell.com
8
+ Version: 2.2
9
  License: GPL2
10
  */
11
  /* Copyright 2013 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.2' );
32
 
33
  // Providers
34
  require_once( VIDEO_THUMBNAILS_PATH . '/php/providers/class-video-thumbnails-providers.php' );
342
 
343
  $video_thumbnails = new Video_Thumbnails();
344
 
345
+ do_action( 'video_thumbnails_plugin_loaded' );
346
+
347
  // End class
348
 
349
  // Get video thumbnail function