WP Video Lightbox - Version 1.6

Version Description

None

Download this release

Release Info

Developer mra13
Plugin Icon 128x128 WP Video Lightbox
Version 1.6
Comparing to
See all releases

Code changes from version 1.5 to 1.6

images/play.png ADDED
Binary file
js/video-lightbox.js CHANGED
@@ -1,4 +1,5 @@
1
  jQuery(document).ready(function($) {
 
2
  $("a[rel^='wp-video-lightbox']").prettyPhoto({
3
  animation_speed: 'fast',
4
  slideshow: 5000,
1
  jQuery(document).ready(function($) {
2
+ //WP Video Lightbox Pluign - http://www.tipsandtricks-hq.com/?p=2700
3
  $("a[rel^='wp-video-lightbox']").prettyPhoto({
4
  animation_speed: 'fast',
5
  slideshow: 5000,
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://www.tipsandtricks-hq.com/
4
  Tags: wordpress lightbox, wordpress video lightbox, video lightbox, wp video lightbox, wordpress video embed, add video to wordpress, gallery, image, images, lightbox, lightview, overlay, photo, photos, picture, video
5
  Requires at least: 3.0
6
  Tested up to: 3.6
7
- Stable tag: 1.5
8
  License: GPLv2 or later
9
 
10
  Very easy to use WordPress lightbox plugin to display YouTube and Vimeo videos in an elegant lightbox overlay.
@@ -38,6 +38,9 @@ Yes
38
  = Can this plugin be used to do lightbox on images? =
39
  Yes
40
 
 
 
 
41
  == Screenshots ==
42
 
43
  Please see this page for screenshots:
@@ -48,7 +51,7 @@ http://www.tipsandtricks-hq.com/?p=2700
48
  None
49
 
50
  == Changelog ==
51
-
52
  1.5 - Made some improvements as to how the JavaScript code is loaded in the plugin. WordPress 3.6 compatibility.
53
  1.4 - added a feature in the shortcode to turn off the related video display after the playback
54
  1.3 - First commit to the wordpress repository
4
  Tags: wordpress lightbox, wordpress video lightbox, video lightbox, wp video lightbox, wordpress video embed, add video to wordpress, gallery, image, images, lightbox, lightview, overlay, photo, photos, picture, video
5
  Requires at least: 3.0
6
  Tested up to: 3.6
7
+ Stable tag: 1.6
8
  License: GPLv2 or later
9
 
10
  Very easy to use WordPress lightbox plugin to display YouTube and Vimeo videos in an elegant lightbox overlay.
38
  = Can this plugin be used to do lightbox on images? =
39
  Yes
40
 
41
+ = Can this plugin automatically create a thumbnail/anchor image from the YouTube video?
42
+ Yes
43
+
44
  == Screenshots ==
45
 
46
  Please see this page for screenshots:
51
  None
52
 
53
  == Changelog ==
54
+ 1.6 - Added an option to automatically create and use the thumbnail of the YouTube or Vimeo video as the anchor image.
55
  1.5 - Made some improvements as to how the JavaScript code is loaded in the plugin. WordPress 3.6 compatibility.
56
  1.4 - added a feature in the shortcode to turn off the related video display after the playback
57
  1.3 - First commit to the wordpress repository
wp-video-lightbox.css ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ .wpvl_auto_thumb_box{
3
+ position: relative;
4
+ width: 200px;
5
+ height: 150px;
6
+ }
7
+
8
+ .wpvl_auto_thumb_play{
9
+ position: absolute;
10
+ left: 75px;
11
+ top: 50px;
12
+ }
13
+
14
+ .video_lightbox_auto_anchor_image{
15
+ width: 200px;
16
+ height: 150px;
17
+ }
wp-video-lightbox.php CHANGED
@@ -1,13 +1,13 @@
1
  <?php
2
  /*
3
  Plugin Name: WP Video Lightbox
4
- Version: 1.5
5
  Plugin URI: http://www.tipsandtricks-hq.com/?p=2700
6
  Author: Tips and Tricks HQ, Ruhul Amin
7
  Author URI: http://www.tipsandtricks-hq.com/
8
  Description: Simple video lightbox plugin to display videos in a nice overlay popup. It also supports images, flash, YouTube, iFrame.
9
  */
10
- define('WP_LICENSE_MANAGER_VERSION', "1.5");
11
  define('WP_VID_LIGHTBOX_URL', plugins_url('',__FILE__));
12
 
13
  add_shortcode('video_lightbox_vimeo5', 'wp_vid_lightbox_vimeo5_handler');
@@ -15,62 +15,127 @@ add_shortcode('video_lightbox_youtube', 'wp_vid_lightbox_youtube_handler');
15
 
16
  function wp_vid_lightbox_vimeo5_handler($atts)
17
  {
18
- extract(shortcode_atts(array(
19
- 'video_id' => '',
20
- 'width' => '',
21
- 'height' => '',
22
- 'anchor' => '',
23
- ), $atts));
24
- if(empty($video_id) || empty($width) || empty($height) ||empty($anchor)){
25
- return "<p>Error! You must specify a value for the Video ID, Width, Height and Anchor parameters to use this shortcode!</p>";
26
- }
27
-
28
- if (preg_match("/http/", $anchor)){ // Use the image as the anchor
29
- $anchor_replacement = '<img src="'.$anchor.'" class="video_lightbox_anchor_image" alt="" />';
 
 
 
 
 
 
 
 
 
30
  }
31
  else {
32
  $anchor_replacement = $anchor;
33
  }
34
  $href_content = 'http://vimeo.com/'.$video_id.'?width='.$width.'&amp;height='.$height;
35
- $output = "";
36
- $output .= '<a rel="wp-video-lightbox" href="'.$href_content.'" title="">'.$anchor_replacement.'</a>';
37
- return $output;
38
  }
39
 
40
  function wp_vid_lightbox_youtube_handler($atts)
41
  {
42
- extract(shortcode_atts(array(
43
- 'video_id' => '',
44
- 'width' => '',
45
- 'height' => '',
46
- 'anchor' => '',
47
- ), $atts));
48
- if(empty($video_id) || empty($width) || empty($height) ||empty($anchor)){
49
- return "<p>Error! You must specify a value for the Video ID, Width, Height and Anchor parameters to use this shortcode!</p>";
50
- }
51
-
52
- if (preg_match("/http/", $anchor)){ // Use the image as the anchor
53
- $anchor_replacement = '<img src="'.$anchor.'" class="video_lightbox_anchor_image" alt="" />';
 
 
 
 
 
 
 
 
 
54
  }
55
  else{
56
  $anchor_replacement = $anchor;
57
  }
58
  $href_content = 'http://www.youtube.com/watch?v='.$video_id.'&amp;width='.$width.'&amp;height='.$height;
59
- $output = '<a rel="wp-video-lightbox" href="'.$href_content.'" title="">'.$anchor_replacement.'</a>';
60
- return $output;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
  }
62
 
63
  function wp_vid_lightbox_init()
64
  {
65
  if (!is_admin())
66
  {
67
- wp_enqueue_script('jquery');
68
- wp_register_script('jquery.prettyphoto', WP_VID_LIGHTBOX_URL.'/js/jquery.prettyPhoto.js', array('jquery'), '3.1.4');
69
- wp_enqueue_script('jquery.prettyphoto');
70
- wp_register_script('video-lightbox', WP_VID_LIGHTBOX_URL.'/js/video-lightbox.js', array('jquery'), '3.1.4');
71
- wp_enqueue_script('video-lightbox');
72
- wp_register_style('jquery.prettyphoto', WP_VID_LIGHTBOX_URL.'/css/prettyPhoto.css');
73
- wp_enqueue_style('jquery.prettyphoto');
 
 
74
  }
75
  }
76
 
1
  <?php
2
  /*
3
  Plugin Name: WP Video Lightbox
4
+ Version: 1.6
5
  Plugin URI: http://www.tipsandtricks-hq.com/?p=2700
6
  Author: Tips and Tricks HQ, Ruhul Amin
7
  Author URI: http://www.tipsandtricks-hq.com/
8
  Description: Simple video lightbox plugin to display videos in a nice overlay popup. It also supports images, flash, YouTube, iFrame.
9
  */
10
+ define('WP_LICENSE_MANAGER_VERSION', "1.6");
11
  define('WP_VID_LIGHTBOX_URL', plugins_url('',__FILE__));
12
 
13
  add_shortcode('video_lightbox_vimeo5', 'wp_vid_lightbox_vimeo5_handler');
15
 
16
  function wp_vid_lightbox_vimeo5_handler($atts)
17
  {
18
+ extract(shortcode_atts(array(
19
+ 'video_id' => '',
20
+ 'width' => '',
21
+ 'height' => '',
22
+ 'anchor' => '',
23
+ 'auto_thumb' => '',
24
+ ), $atts));
25
+ if(empty($video_id) || empty($width) || empty($height)){
26
+ return "<p>Error! You must specify a value for the Video ID, Width, Height and Anchor parameters to use this shortcode!</p>";
27
+ }
28
+ if(empty($auto_thumb) && empty($anchor)){
29
+ return "<p>Error! You must specify an anchor parameter if you are not using the auto_thumb option.</p>";
30
+ }
31
+
32
+ $atts['vid_type'] = "vimeo";
33
+ if (preg_match("/http/", $anchor)){ // Use the image as the anchor
34
+ $anchor_replacement = '<img src="'.$anchor.'" class="video_lightbox_anchor_image" alt="" />';
35
+ }
36
+ else if($auto_thumb == "1")
37
+ {
38
+ $anchor_replacement = wp_vid_lightbox_get_auto_thumb($atts);
39
  }
40
  else {
41
  $anchor_replacement = $anchor;
42
  }
43
  $href_content = 'http://vimeo.com/'.$video_id.'?width='.$width.'&amp;height='.$height;
44
+ $output = "";
45
+ $output .= '<a rel="wp-video-lightbox" href="'.$href_content.'" title="">'.$anchor_replacement.'</a>';
46
+ return $output;
47
  }
48
 
49
  function wp_vid_lightbox_youtube_handler($atts)
50
  {
51
+ extract(shortcode_atts(array(
52
+ 'video_id' => '',
53
+ 'width' => '',
54
+ 'height' => '',
55
+ 'anchor' => '',
56
+ 'auto_thumb' => '',
57
+ ), $atts));
58
+ if(empty($video_id) || empty($width) || empty($height)){
59
+ return "<p>Error! You must specify a value for the Video ID, Width, Height parameters to use this shortcode!</p>";
60
+ }
61
+ if(empty($auto_thumb) && empty($anchor)){
62
+ return "<p>Error! You must specify an anchor parameter if you are not using the auto_thumb option.</p>";
63
+ }
64
+
65
+ $atts['vid_type'] = "youtube";
66
+ if(preg_match("/http/", $anchor)){ // Use the image as the anchor
67
+ $anchor_replacement = '<img src="'.$anchor.'" class="video_lightbox_anchor_image" alt="" />';
68
+ }
69
+ else if($auto_thumb == "1")
70
+ {
71
+ $anchor_replacement = wp_vid_lightbox_get_auto_thumb($atts);
72
  }
73
  else{
74
  $anchor_replacement = $anchor;
75
  }
76
  $href_content = 'http://www.youtube.com/watch?v='.$video_id.'&amp;width='.$width.'&amp;height='.$height;
77
+ $output = '<a rel="wp-video-lightbox" href="'.$href_content.'" title="">'.$anchor_replacement.'</a>';
78
+ return $output;
79
+ }
80
+
81
+ function wp_vid_lightbox_get_auto_thumb($atts)
82
+ {
83
+ $video_id = $atts['video_id'];
84
+ $pieces = explode("&", $video_id);
85
+ $video_id = $pieces[0];
86
+
87
+ $anchor_replacement = "";
88
+ if($atts['vid_type']=="youtube")
89
+ {
90
+ $anchor_replacement = '<div class="wpvl_auto_thumb_box_wrapper"><div class="wpvl_auto_thumb_box">';
91
+ $anchor_replacement .= '<img src="http://img.youtube.com/vi/'.$video_id.'/0.jpg" class="video_lightbox_auto_anchor_image" alt="" />';
92
+ $anchor_replacement .= '<div class="wpvl_auto_thumb_play"><img src="'.WP_VID_LIGHTBOX_URL.'/images/play.png" class="wpvl_playbutton" /></div>';
93
+ $anchor_replacement .= '</div></div>';
94
+ }
95
+ else if($atts['vid_type']=="vimeo")
96
+ {
97
+ $VideoInfo = wp_vid_lightbox_getVimeoInfo($video_id);
98
+ $thumb = $VideoInfo['thumbnail_medium'];
99
+ //print_r($VideoInfo);
100
+ $anchor_replacement = '<div class="wpvl_auto_thumb_box_wrapper"><div class="wpvl_auto_thumb_box">';
101
+ $anchor_replacement .= '<img src="'.$thumb.'" class="video_lightbox_auto_anchor_image" alt="" />';
102
+ $anchor_replacement .= '<div class="wpvl_auto_thumb_play"><img src="'.WP_VID_LIGHTBOX_URL.'/images/play.png" class="wpvl_playbutton" /></div>';
103
+ $anchor_replacement .= '</div></div>';
104
+ }
105
+ else
106
+ {
107
+ wp_die("<p>no video type specified</p>");
108
+ }
109
+ return $anchor_replacement;
110
+ }
111
+
112
+ function wp_vid_lightbox_getVimeoInfo($id)
113
+ {
114
+ if (!function_exists('curl_init')) die('CURL is not installed!');
115
+ $ch = curl_init();
116
+ curl_setopt($ch, CURLOPT_URL, "http://vimeo.com/api/v2/video/$id.php");
117
+ curl_setopt($ch, CURLOPT_HEADER, 0);
118
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
119
+ curl_setopt($ch, CURLOPT_TIMEOUT, 10);
120
+ $output = unserialize(curl_exec($ch));
121
+ $output = $output[0];
122
+ curl_close($ch);
123
+ return $output;
124
  }
125
 
126
  function wp_vid_lightbox_init()
127
  {
128
  if (!is_admin())
129
  {
130
+ wp_enqueue_script('jquery');
131
+ wp_register_script('jquery.prettyphoto', WP_VID_LIGHTBOX_URL.'/js/jquery.prettyPhoto.js', array('jquery'), '3.1.4');
132
+ wp_enqueue_script('jquery.prettyphoto');
133
+ wp_register_script('video-lightbox', WP_VID_LIGHTBOX_URL.'/js/video-lightbox.js', array('jquery'), '3.1.4');
134
+ wp_enqueue_script('video-lightbox');
135
+ wp_register_style('jquery.prettyphoto', WP_VID_LIGHTBOX_URL.'/css/prettyPhoto.css');
136
+ wp_enqueue_style('jquery.prettyphoto');
137
+ wp_register_style('video-lightbox', WP_VID_LIGHTBOX_URL.'/wp-video-lightbox.css');
138
+ wp_enqueue_style('video-lightbox');
139
  }
140
  }
141