WP jQuery Lightbox - Version 1.2

Version Description

Support caption and titles from the Media Library

Download this release

Release Info

Developer ulfben
Plugin Icon wp plugin WP jQuery Lightbox
Version 1.2
Comparing to
See all releases

Code changes from version 1.1 to 1.2

jquery.lightbox.js CHANGED
@@ -10,13 +10,17 @@
10
  * Originally written to make use of the Prototype framework, and Script.acalo.us, now altered to use jQuery.
11
  *
12
  * This file was lightly modified by Ulf Benjaminsson (http://www.ulfben.com) for use in the WP jQuery Lightbox-
13
- * plugin. Modifications include:
 
14
  * 0. using no-conflict mode (for good measure)
15
  * 1. improved the resizing code
16
  * 2. using rel attribute instead of class
17
  * 3. auto-lightboxing all links after page load
18
  * 4. using WordPress API to localize script (with safe fallbacks)
19
  * 5. replaced explicit IMG-urls with divs, styled through the CSS.
 
 
 
20
  *
21
  **/
22
  (function(jQuery){
@@ -55,9 +59,9 @@
55
  var outerImage = '<div id="outerImageContainer"><div id="imageContainer"><iframe id="lightboxIframe" /><img id="lightboxImage"><div id="hoverNav"><a href="javascript://" title="' + opts.strings.prevLinkTitle + '" id="prevLink"></a><a href="javascript://" id="nextLink" title="' + opts.strings.nextLinkTitle + '"></a></div><div id="loading"><a href="javascript://" id="loadingLink"><div id="jqlb_loading"></div></a></div></div></div>';
56
  var imageData = '<div id="imageDataContainer" class="clearfix"><div id="imageData"><div id="imageDetails"><span id="caption"></span><span id="numberDisplay"></span></div><div id="bottomNav">';
57
 
58
- if (opts.displayHelp)
59
  imageData += '<span id="helpDisplay">' + opts.strings.help + '</span>';
60
-
61
  imageData += '<a href="javascript://" id="bottomNavClose" title="' + opts.strings.closeTitle + '"><div id="jqlb_closelabel"></div></a></div></div></div>';
62
 
63
  var string;
@@ -91,7 +95,6 @@
91
 
92
  function getPageScroll() {
93
  var xScroll, yScroll;
94
-
95
  if (self.pageYOffset) {
96
  yScroll = self.pageYOffset;
97
  xScroll = self.pageXOffset;
@@ -102,7 +105,6 @@
102
  yScroll = document.body.scrollTop;
103
  xScroll = document.body.scrollLeft;
104
  }
105
-
106
  var arrayPageScroll = new Array(xScroll,yScroll);
107
  return arrayPageScroll;
108
  };
@@ -113,25 +115,52 @@
113
  do{curDate = new Date();}
114
  while(curDate - date < ms);
115
  };
116
-
117
  function start(imageLink) {
118
  jQuery("select, embed, object").hide();
119
  var arrayPageSize = getPageSize();
120
  jQuery("#overlay").hide().css({width: '100%', height: arrayPageSize[1]+'px', opacity : opts.overlayOpacity}).fadeIn(400);
121
  imageNum = 0;
122
-
123
  // if data is not provided by jsonData parameter
124
  if(!opts.jsonData) {
125
- opts.imageArray = [];
126
- // if image is NOT part of a set..
127
  if(!imageLink.rel || (imageLink.rel == '')){
128
  // add single image to Lightbox.imageArray
129
- opts.imageArray.push(new Array(imageLink.href, opts.displayTitle ? imageLink.title : ''));
130
- } else {
 
 
 
 
 
 
 
131
  // if image is part of a set..
132
  jQuery("a").each(function(){
133
  if(this.href && (this.rel == imageLink.rel)){
134
- opts.imageArray.push(new Array(this.href, opts.displayTitle ? this.title : ''));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
135
  }
136
  });
137
  }
@@ -141,7 +170,7 @@
141
  for(i = 0; i < opts.imageArray.length; i++){
142
  for(j = opts.imageArray.length-1; j>i; j--){
143
  if(opts.imageArray[i][0] == opts.imageArray[j][0]){
144
- opts.imageArray.splice(j,1);
145
  }
146
  }
147
  }
@@ -155,9 +184,9 @@
155
  jQuery('#lightbox').css({top: lightboxTop+'px', left: lightboxLeft+'px'}).show();
156
 
157
 
158
- if (!opts.slideNavBar)
159
  jQuery('#imageData').hide();
160
-
161
  changeImage(imageNum);
162
  };
163
 
10
  * Originally written to make use of the Prototype framework, and Script.acalo.us, now altered to use jQuery.
11
  *
12
  * This file was lightly modified by Ulf Benjaminsson (http://www.ulfben.com) for use in the WP jQuery Lightbox-
13
+ * plugin. (http://wordpress.org/extend/plugins/wp-jquery-lightbox/)
14
+ * Modifications include:
15
  * 0. using no-conflict mode (for good measure)
16
  * 1. improved the resizing code
17
  * 2. using rel attribute instead of class
18
  * 3. auto-lightboxing all links after page load
19
  * 4. using WordPress API to localize script (with safe fallbacks)
20
  * 5. replaced explicit IMG-urls with divs, styled through the CSS.
21
+ * 6. honors empty captions / titles
22
+ * 7. grabs image caption from WordPress [gallery] or media library output
23
+ * 8. grabs image title if the link lacks one
24
  *
25
  **/
26
  (function(jQuery){
59
  var outerImage = '<div id="outerImageContainer"><div id="imageContainer"><iframe id="lightboxIframe" /><img id="lightboxImage"><div id="hoverNav"><a href="javascript://" title="' + opts.strings.prevLinkTitle + '" id="prevLink"></a><a href="javascript://" id="nextLink" title="' + opts.strings.nextLinkTitle + '"></a></div><div id="loading"><a href="javascript://" id="loadingLink"><div id="jqlb_loading"></div></a></div></div></div>';
60
  var imageData = '<div id="imageDataContainer" class="clearfix"><div id="imageData"><div id="imageDetails"><span id="caption"></span><span id="numberDisplay"></span></div><div id="bottomNav">';
61
 
62
+ if (opts.displayHelp){
63
  imageData += '<span id="helpDisplay">' + opts.strings.help + '</span>';
64
+ }
65
  imageData += '<a href="javascript://" id="bottomNavClose" title="' + opts.strings.closeTitle + '"><div id="jqlb_closelabel"></div></a></div></div></div>';
66
 
67
  var string;
95
 
96
  function getPageScroll() {
97
  var xScroll, yScroll;
 
98
  if (self.pageYOffset) {
99
  yScroll = self.pageYOffset;
100
  xScroll = self.pageXOffset;
105
  yScroll = document.body.scrollTop;
106
  xScroll = document.body.scrollLeft;
107
  }
 
108
  var arrayPageScroll = new Array(xScroll,yScroll);
109
  return arrayPageScroll;
110
  };
115
  do{curDate = new Date();}
116
  while(curDate - date < ms);
117
  };
118
+
119
  function start(imageLink) {
120
  jQuery("select, embed, object").hide();
121
  var arrayPageSize = getPageSize();
122
  jQuery("#overlay").hide().css({width: '100%', height: arrayPageSize[1]+'px', opacity : opts.overlayOpacity}).fadeIn(400);
123
  imageNum = 0;
 
124
  // if data is not provided by jsonData parameter
125
  if(!opts.jsonData) {
126
+ opts.imageArray = [];
127
+ // if image is NOT part of a set..
128
  if(!imageLink.rel || (imageLink.rel == '')){
129
  // add single image to Lightbox.imageArray
130
+ var s = '';
131
+ if(imageLink.title){
132
+ s = imageLink.title;
133
+ }else if(jQuery(this).children(':first-child').attr('title')){
134
+ s = jQuery(this).children(':first-child').attr('title');
135
+ }
136
+ alert("single");
137
+ opts.imageArray.push(new Array(imageLink.href, opts.displayTitle ? s : ''));
138
+ } else {
139
  // if image is part of a set..
140
  jQuery("a").each(function(){
141
  if(this.href && (this.rel == imageLink.rel)){
142
+ var title = '';
143
+ var caption = '';
144
+ var jqThis = jQuery(this);
145
+ if(this.title){
146
+ title = this.title;
147
+ }else if(jqThis.children('img:first-child').attr('title')){
148
+ title = jqThis.children('img:first-child').attr('title');//grab the title from the image if the link lacks one
149
+ }
150
+ if(jqThis.parent().next('.gallery-caption').html()){
151
+ caption = jqThis.parent().next('.gallery-caption').html();
152
+ }else if(jqThis.next('.wp-caption-text').html()){
153
+ caption = jqThis.next('.wp-caption-text').html();
154
+ }
155
+ var s = '';
156
+ if(title != '' && caption != ''){
157
+ s = title+'<br />'+caption;
158
+ }else if(title != ''){
159
+ s = title;
160
+ }else if(caption != ''){
161
+ s = caption;
162
+ }
163
+ opts.imageArray.push(new Array(this.href, opts.displayTitle ? s : ''));
164
  }
165
  });
166
  }
170
  for(i = 0; i < opts.imageArray.length; i++){
171
  for(j = opts.imageArray.length-1; j>i; j--){
172
  if(opts.imageArray[i][0] == opts.imageArray[j][0]){
173
+ opts.imageArray.splice(j,1);
174
  }
175
  }
176
  }
184
  jQuery('#lightbox').css({top: lightboxTop+'px', left: lightboxLeft+'px'}).show();
185
 
186
 
187
+ if (!opts.slideNavBar){
188
  jQuery('#imageData').hide();
189
+ }
190
  changeImage(imageNum);
191
  };
192
 
jquery.lightbox.min.js ADDED
@@ -0,0 +1 @@
 
1
+ (function(a){a.fn.lightbox=function(h){var s=a.extend({},a.fn.lightbox.defaults,h);return this.each(function(){a(this).click(function(){e();n(this);return false})});function e(){a("#overlay").remove();a("#lightbox").remove();s.inprogress=false;if(s.jsonData&&s.jsonData.length>0){var y=s.jsonDataParser?s.jsonDataParser:a.fn.lightbox.parseJsonData;s.imageArray=[];s.imageArray=y(s.jsonData)}var v='<div id="outerImageContainer"><div id="imageContainer"><iframe id="lightboxIframe" /><img id="lightboxImage"><div id="hoverNav"><a href="javascript://" title="'+s.strings.prevLinkTitle+'" id="prevLink"></a><a href="javascript://" id="nextLink" title="'+s.strings.nextLinkTitle+'"></a></div><div id="loading"><a href="javascript://" id="loadingLink"><div id="jqlb_loading"></div></a></div></div></div>';var x='<div id="imageDataContainer" class="clearfix"><div id="imageData"><div id="imageDetails"><span id="caption"></span><span id="numberDisplay"></span></div><div id="bottomNav">';if(s.displayHelp){x+='<span id="helpDisplay">'+s.strings.help+"</span>"}x+='<a href="javascript://" id="bottomNavClose" title="'+s.strings.closeTitle+'"><div id="jqlb_closelabel"></div></a></div></div></div>';var w;if(s.navbarOnTop){w='<div id="overlay"></div><div id="lightbox">'+x+v+"</div>";a("body").append(w);a("#imageDataContainer").addClass("ontop")}else{w='<div id="overlay"></div><div id="lightbox">'+v+x+"</div>";a("body").append(w)}a("#overlay").click(function(){l()}).hide();a("#lightbox").click(function(){l()}).hide();a("#loadingLink").click(function(){l();return false});a("#bottomNavClose").click(function(){l();return false});a("#outerImageContainer").width(s.widthCurrent).height(s.heightCurrent);a("#imageDataContainer").width(s.widthCurrent);if(!s.imageClickClose){a("#lightboxImage").click(function(){return false});a("#hoverNav").click(function(){return false})}}function u(){var v=new Array(a(document).width(),a(document).height(),a(window).width(),a(window).height());return v}function g(){var x,v;if(self.pageYOffset){v=self.pageYOffset;x=self.pageXOffset}else{if(document.documentElement&&document.documentElement.scrollTop){v=document.documentElement.scrollTop;x=document.documentElement.scrollLeft}else{if(document.body){v=document.body.scrollTop;x=document.body.scrollLeft}}}var w=new Array(x,v);return w}function o(x){var w=new Date();var v=null;do{v=new Date()}while(v-w<x)}function n(A){a("select, embed, object").hide();var w=u();a("#overlay").hide().css({width:"100%",height:w[1]+"px",opacity:s.overlayOpacity}).fadeIn(400);imageNum=0;if(!s.jsonData){s.imageArray=[];if(!A.rel||(A.rel=="")){var x="";if(A.title){x=A.title}else{if(a(this).children(":first-child").attr("title")){x=a(this).children(":first-child").attr("title")}}alert("single");s.imageArray.push(new Array(A.href,s.displayTitle?x:""))}else{a("a").each(function(){if(this.href&&(this.rel==A.rel)){var E="";var C="";var B=a(this);if(this.title){E=this.title}else{if(B.children("img:first-child").attr("title")){E=B.children("img:first-child").attr("title")}}if(B.parent().next(".gallery-caption").html()){C=B.parent().next(".gallery-caption").html()}else{if(B.next(".wp-caption-text").html()){C=B.next(".wp-caption-text").html()}}var D="";if(E!=""&&C!=""){D=E+"<br />"+C}else{if(E!=""){D=E}else{if(C!=""){D=C}}}s.imageArray.push(new Array(this.href,s.displayTitle?D:""))}})}}if(s.imageArray.length>1){for(i=0;i<s.imageArray.length;i++){for(j=s.imageArray.length-1;j>i;j--){if(s.imageArray[i][0]==s.imageArray[j][0]){s.imageArray.splice(j,1)}}}while(s.imageArray[imageNum][0]!=A.href){imageNum++}}var v=g();var z=v[1]+(w[3]/10);var y=v[0];a("#lightbox").css({top:z+"px",left:y+"px"}).show();if(!s.slideNavBar){a("#imageData").hide()}t(imageNum)}function t(v){if(s.inprogress==false){s.inprogress=true;s.activeImage=v;a("#loading").show();a("#lightboxImage").hide();a("#hoverNav").hide();a("#prevLink").hide();a("#nextLink").hide();if(s.slideNavBar){a("#imageDataContainer").hide();a("#imageData").hide();k()}else{k()}}}function k(){imgPreloader=new Image();imgPreloader.onload=function(){var A=imgPreloader.width;var v=imgPreloader.height;if(s.fitToScreen){var w=u();var z=w[2]-3*s.borderSize;var y=w[3]-200;var x=1;if(v>y){x=y/v}A=A*x;v=v*x;x=1;if(A>z){x=z/A}A=A*x;v=v*x}a("#lightboxImage").attr("src",s.imageArray[s.activeImage][0]).width(A).height(v);m(A,v)};imgPreloader.src=s.imageArray[s.activeImage][0]}function l(){p();a("#lightbox").hide();a("#overlay").fadeOut(250);a("select, object, embed").show()}function f(){if(s.loopImages&&s.imageArray.length>1){preloadNextImage=new Image();preloadNextImage.src=s.imageArray[(s.activeImage==(s.imageArray.length-1))?0:s.activeImage+1][0];preloadPrevImage=new Image();preloadPrevImage.src=s.imageArray[(s.activeImage==0)?(s.imageArray.length-1):s.activeImage-1][0]}else{if((s.imageArray.length-1)>s.activeImage){preloadNextImage=new Image();preloadNextImage.src=s.imageArray[s.activeImage+1][0]}if(s.activeImage>0){preloadPrevImage=new Image();preloadPrevImage.src=s.imageArray[s.activeImage-1][0]}}}function m(y,w){s.widthCurrent=a("#outerImageContainer").outerWidth();s.heightCurrent=a("#outerImageContainer").outerHeight();var v=Math.max(350,y+(s.borderSize*2));var x=(w+(s.borderSize*2));s.xScale=(v/s.widthCurrent)*100;s.yScale=(x/s.heightCurrent)*100;wDiff=s.widthCurrent-v;hDiff=s.heightCurrent-x;a("#imageDataContainer").animate({width:v},s.resizeSpeed,"linear");a("#outerImageContainer").animate({width:v},s.resizeSpeed,"linear",function(){a("#outerImageContainer").animate({height:x},s.resizeSpeed,"linear",function(){d()})});if((hDiff==0)&&(wDiff==0)){if(a.browser.msie){o(250)}else{o(100)}}a("#prevLink").height(w);a("#nextLink").height(w)}function d(){a("#loading").hide();a("#lightboxImage").fadeIn(400);c();f();s.inprogress=false}function c(){a("#numberDisplay").html("");a("#imageDataContainer").slideDown("fast");a("#caption").hide();if(s.imageArray[s.activeImage][1]){a("#caption").html(s.imageArray[s.activeImage][1]).show()}if(s.imageArray.length>1){var w;w=s.strings.image+(s.activeImage+1)+s.strings.of+s.imageArray.length;if(!s.disableNavbarLinks){if((s.activeImage)>0||s.loopImages){w='<a title="'+s.strings.prevLinkTitle+'" href="#" id="prevLinkText">'+s.strings.prevLinkText+"</a>"+w}if(((s.activeImage+1)<s.imageArray.length)||s.loopImages){w+='<a title="'+s.strings.nextLinkTitle+'" href="#" id="nextLinkText">'+s.strings.nextLinkText+"</a>"}}a("#numberDisplay").html(w).show()}if(s.slideNavBar){a("#imageData").slideDown(s.navBarSlideSpeed)}else{a("#imageData").show()}var v=u();a("#overlay").height(v[1]);q()}function q(){if(s.imageArray.length>1){a("#hoverNav").show();if(s.loopImages){a("#prevLink,#prevLinkText").show().click(function(){t((s.activeImage==0)?(s.imageArray.length-1):s.activeImage-1);return false});a("#nextLink,#nextLinkText").show().click(function(){t((s.activeImage==(s.imageArray.length-1))?0:s.activeImage+1);return false})}else{if(s.activeImage!=0){a("#prevLink,#prevLinkText").show().click(function(){t(s.activeImage-1);return false})}if(s.activeImage!=(s.imageArray.length-1)){a("#nextLink,#nextLinkText").show().click(function(){t(s.activeImage+1);return false})}}b()}}function r(y){var z=y.data.opts;var v=y.keyCode;var w=27;var x=String.fromCharCode(v).toLowerCase();if((x=="x")||(x=="o")||(x=="c")||(v==w)){l()}else{if((x=="p")||(v==37)){if(z.loopImages){p();t((z.activeImage==0)?(z.imageArray.length-1):z.activeImage-1)}else{if(z.activeImage!=0){p();t(z.activeImage-1)}}}else{if((x=="n")||(v==39)){if(s.loopImages){p();t((z.activeImage==(z.imageArray.length-1))?0:z.activeImage+1)}else{if(z.activeImage!=(z.imageArray.length-1)){p();t(z.activeImage+1)}}}}}}function b(){a(document).bind("keydown",{opts:s},r)}function p(){a(document).unbind("keydown")}};a.fn.lightbox.parseJsonData=function(c){var b=[];a.each(c,function(){b.push(new Array(this.url,this.title))});return b};a.fn.lightbox.defaults={overlayOpacity:0.8,borderSize:10,imageArray:new Array,activeImage:null,inprogress:false,resizeSpeed:250,widthCurrent:250,heightCurrent:250,xScale:1,yScale:1,displayTitle:true,navbarOnTop:false,slideNavBar:false,navBarSlideSpeed:250,displayHelp:false,strings:{help:" \u2190 / P - previous image\u00a0\u00a0\u00a0\u00a0\u2192 / N - next image\u00a0\u00a0\u00a0\u00a0ESC / X - close image gallery",prevLinkTitle:"previous image",nextLinkTitle:"next image",prevLinkText:"&laquo; Previous",nextLinkText:"Next &raquo;",closeTitle:"close image gallery",image:"Image ",of:" of "},fitToScreen:false,disableNavbarLinks:true,loopImages:true,imageClickClose:true,jsonData:null,jsonDataParser:null}})(jQuery);jQuery(document).ready(function(){jQuery('a[rel^="lightbox"]').lightbox({fitToScreen:(typeof JQLBSettings=="object"&&JQLBSettings.fitToScreen=="1")?true:false,resizeSpeed:(typeof JQLBSettings=="object"&&JQLBSettings.resizeSpeed>0)?JQLBSettings.resizeSpeed:250,imageClickClose:true})});
css/lightbox.css → lightbox.css RENAMED
@@ -9,13 +9,13 @@
9
 
10
  #jqlb_loading{
11
  height:32px;
12
- background-image:url('../images/loading.gif');
13
  background-repeat:no-repeat;
14
  background-position:center center;
15
  }
16
  #jqlb_closelabel{
17
  height:22px;
18
- background-image:url('../images/closelabel.gif');
19
  background-repeat:no-repeat;
20
  background-position:center center;
21
  }
@@ -57,13 +57,13 @@
57
  #prevLink, #nextLink{
58
  width: 49%;
59
  height: 100%;
60
- background: transparent url('../images/blank.gif') no-repeat; /* Trick IE into showing hover */
61
  display: block;
62
  }
63
  #prevLink { left: 0; float: left;}
64
  #nextLink { right: 0; float: right;}
65
- #prevLink:hover, #prevLink:visited:hover { background: url('../images/prev.gif') left 50% no-repeat; }
66
- #nextLink:hover, #nextLink:visited:hover { background: url('../images/next.gif') right 50% no-repeat; }
67
 
68
  /*** START : next / previous text links ***/
69
  #nextLinkText, #prevLinkText{
9
 
10
  #jqlb_loading{
11
  height:32px;
12
+ background-image:url('./images/loading.gif');
13
  background-repeat:no-repeat;
14
  background-position:center center;
15
  }
16
  #jqlb_closelabel{
17
  height:22px;
18
+ background-image:url('./images/closelabel.gif');
19
  background-repeat:no-repeat;
20
  background-position:center center;
21
  }
57
  #prevLink, #nextLink{
58
  width: 49%;
59
  height: 100%;
60
+ background: transparent url('./images/blank.gif') no-repeat; /* Trick IE into showing hover */
61
  display: block;
62
  }
63
  #prevLink { left: 0; float: left;}
64
  #nextLink { right: 0; float: right;}
65
+ #prevLink:hover, #prevLink:visited:hover { background: url('./images/prev.gif') left 50% no-repeat; }
66
+ #nextLink:hover, #nextLink:visited:hover { background: url('./images/next.gif') right 50% no-repeat; }
67
 
68
  /*** START : next / previous text links ***/
69
  #nextLinkText, #prevLinkText{
lightbox.min.css ADDED
@@ -0,0 +1 @@
 
1
+ #lightbox{position:absolute;left:0;width:100%;z-index:100;text-align:center;line-height:0}#jqlb_loading{height:32px;background-image:url('./images/loading.gif');background-repeat:no-repeat;background-position:center center}#jqlb_closelabel{height:22px;background-image:url('./images/closelabel.gif');background-repeat:no-repeat;background-position:center center}#lightbox a img{border:none}#outerImageContainer{position:relative;background-color:#fff;width:250px;height:250px;margin:0 auto}#imageContainer{padding:10px}#loading{position:absolute;top:40%;left:0;height:25%;width:100%;text-align:center;line-height:0}#hoverNav{position:absolute;top:0;left:0;height:100%;width:100%;z-index:10}#imageContainer>#hoverNav{left:0}#hoverNav a{outline:none}#prevLink,#nextLink{width:49%;height:100%;background:transparent url('./images/blank.gif') no-repeat;display:block}#prevLink{left:0;float:left}#nextLink{right:0;float:right}#prevLink:hover,#prevLink:visited:hover{background:url('./images/prev.gif') left 50% no-repeat}#nextLink:hover,#nextLink:visited:hover{background:url('./images/next.gif') right 50% no-repeat}#nextLinkText,#prevLinkText{color:#ff9834;font-weight:bold;text-decoration:none}#nextLinkText{padding-left:20px}#prevLinkText{padding-right:20px}.ontop #imageData{padding-top:5px}#imageDataContainer{font:10px Verdana,Helvetica,sans-serif;background-color:#fff;margin:0 auto;line-height:1.4em}#imageData{padding:0 10px}#imageData #imageDetails{width:70%;float:left;text-align:left}#imageData #caption{font-weight:bold}#imageData #numberDisplay{display:block;clear:left;padding-bottom:1.0em}#imageData #bottomNavClose{width:66px;float:right;padding-bottom:.7em}#imageData #helpDisplay{clear:left;float:left;display:block}#overlay{position:absolute;top:0;left:0;z-index:90;width:100%;height:500px;background-color:#000;filter:alpha(opacity=60);-moz-opacity:.6;opacity:.6;display:none}.clearfix:after{content:".";display:block;height:0;clear:both;visibility:hidden}* html>body .clearfix{display:inline-block;width:100%}* html .clearfix{/*\*/height:1%;/**/}#lightboxIframe{display:none}
readme.txt CHANGED
@@ -4,21 +4,30 @@ Donate link: http://amzn.com/w/2QB6SQ5XX2U0N
4
  Tags: lightbox, jquery, nodal, image, display, ulfben
5
  Requires at least: 2.9.2
6
  Tested up to: 3.0.1
7
- Stable tag: 1.1
8
 
9
- A drop in replacement for Lightbox 2 and similar plugins, shedding the bulk of Prototype and Scriptaculous.
10
 
11
  == Description ==
12
 
13
  This plugin lets you keep [the awesome Lightbox 2](http://www.huddletogether.com/projects/lightbox2/)-functionality, but sheds the bulk of the Prototype Framework **and** Scriptaculous Effects Library.
14
 
15
  Warren Krewenki [ported Lightbox over to jQuery](http://warren.mesozen.com/jquery-lightbox/) and this plugin is mostly a wrapper to his work.
16
- It provides an admin panel for configuration, (optional) auto-boxing of your image links and support for WordPress galleries.
17
 
18
- You can configure the animation speed and disable image resizing (if you don't want the plugin to fit images to smaller monitors).
19
 
20
  See the plugin in action here: [http://game.hgo.se/blog/motion-capture/](http://game.hgo.se/blog/motion-capture/)
21
 
 
 
 
 
 
 
 
 
 
22
  == Installation ==
23
 
24
  1. Upload the `wp-jquery-lightbox`-folder to the `/wp-content/plugins/` directory
@@ -47,18 +56,38 @@ No limits to the number of image sets per page or how many images are allowed in
47
 
48
  == Changelog ==
49
 
50
- = 1.1 =
 
 
 
 
 
51
  * Honors empty captions.
52
  * Fixed typos on admin page.
53
  * (thanks, josephknight! http://tinyurl.com/3677p6r)
54
 
55
- = 1.0 =
56
  * Release.
57
 
58
  == Upgrade Notice ==
59
 
 
 
 
60
  = 1.1 =
61
  Honors empty captions and fixes some typos.
62
 
63
  = 1.0 =
64
- First release.
 
 
 
 
 
 
 
 
 
 
 
 
4
  Tags: lightbox, jquery, nodal, image, display, ulfben
5
  Requires at least: 2.9.2
6
  Tested up to: 3.0.1
7
+ Stable tag: 1.2
8
 
9
+ A drop-in replacement for Lightbox 2 and similar plugins, shedding the bulk of Prototype and Scriptaculous.
10
 
11
  == Description ==
12
 
13
  This plugin lets you keep [the awesome Lightbox 2](http://www.huddletogether.com/projects/lightbox2/)-functionality, but sheds the bulk of the Prototype Framework **and** Scriptaculous Effects Library.
14
 
15
  Warren Krewenki [ported Lightbox over to jQuery](http://warren.mesozen.com/jquery-lightbox/) and this plugin is mostly a wrapper to his work.
16
+ It provides an admin panel for configuration, (optional) auto-boxing of your image links and support for WordPress galleries, *including* [media library](http://codex.wordpress.org/Media_Library_SubPanel) titles and captions.
17
 
18
+ Navigate the images with your keyboard: Arrows, P(revious)/N(ext) and X/C/ESC for close.
19
 
20
  See the plugin in action here: [http://game.hgo.se/blog/motion-capture/](http://game.hgo.se/blog/motion-capture/)
21
 
22
+ *If you value [my plugins](http://profiles.wordpress.org/users/ulfben/) and want to motivate further development - please **help me out** by [downloading and installing DropBox](http://www.dropbox.com/referrals/NTIzMDI3MDk) from my refferal link. It's a cross-plattform application to sync your files online and across computers. A 2GB account is free and my refferal earns you a 250MB bonus!*
23
+
24
+ = 1.2 (2010-10-12) =
25
+ * Added support for Media Library titles and captions.
26
+ * Minified the javascript (8.6KB vs 17.8KB)
27
+ * Minified the CSS (2.0KB vs 2.7KB)
28
+
29
+ [Older changelogs moved here.](http://wordpress.org/extend/plugins/wp-jquery-lightbox/changelog/)
30
+
31
  == Installation ==
32
 
33
  1. Upload the `wp-jquery-lightbox`-folder to the `/wp-content/plugins/` directory
56
 
57
  == Changelog ==
58
 
59
+ = 1.2 (2010-10-12) =
60
+ * Added support for Media Library titles and captions.
61
+ * Minified the javascript (8.6KB vs 17.8KB)
62
+ * Minified the CSS (2.0KB vs 2.7KB)
63
+
64
+ = 1.1 (2010-10-09) =
65
  * Honors empty captions.
66
  * Fixed typos on admin page.
67
  * (thanks, josephknight! http://tinyurl.com/3677p6r)
68
 
69
+ = 1.0 (2010-04-11) =
70
  * Release.
71
 
72
  == Upgrade Notice ==
73
 
74
+ = 1.2 =
75
+ Support caption and titles from the Media Library
76
+
77
  = 1.1 =
78
  Honors empty captions and fixes some typos.
79
 
80
  = 1.0 =
81
+ First release.
82
+
83
+ == Frequently Asked Questions ==
84
+
85
+ = Must fade-in and animation of all *box-scripts be so slow? =
86
+
87
+ WP-jQuery Lightbox lets you configure the animation speed and disable image resizing from the admin panel.
88
+
89
+ = Can I help you in any way? =
90
+
91
+ Absolutely! If you [download & install DropBox](http://www.dropbox.com/referrals/NTIzMDI3MDk) on my refferal, I get 1GB (much needed!) extra space. DropBox is a cross-plattform application to sync your files online and across computers, and a 2GB account is *free*. Also - my refferal earns you a 250MB bonus!
92
+
93
+ If you've had any commercial applications for my plugins, please consider [sending me a book or two](http://www.amazon.com/gp/registry/wishlist/2QB6SQ5XX2U0N/105-3209188-5640446?reveal=unpurchased&filter=all&sort=priority&layout=standard&x). (used are fine!)
wp-jquery-lightbox.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: wp-jquery-lightbox
4
  Plugin URI: http://wordpress.org/extend/plugins/wp-jquery-lightbox/
5
  Description: A drop in replacement for LightBox-2 and similar plugins. Uses jQuery to save you from the JS-library mess in your header. :)
6
- Version: 1.1
7
  Author: Ulf Benjaminsson
8
  Author URI: http://www.ulfben.com
9
  */
@@ -14,8 +14,8 @@ if(!defined('WP_PLUGIN_URL')){
14
  define('WP_PLUGIN_URL', WP_CONTENT_URL.'/plugins');
15
  }
16
  define('JQLB_URL', WP_PLUGIN_URL.'/wp-jquery-lightbox/');
17
- define('JQLB_SCRIPT_URL', JQLB_URL.'jquery.lightbox.js');
18
- define('JQLB_STYLE_URL', JQLB_URL.'css/lightbox.css');
19
  add_action('admin_menu', 'jqlb_register_menu_item');
20
  add_action('wp_print_styles', 'jqlb_css');
21
  add_action('wp_print_scripts', 'jqlb_js');
@@ -38,14 +38,14 @@ function jqlb_register_menu_item() {
38
  }
39
  function jqlb_css(){
40
  if(is_admin() || is_feed()){return;}
41
- wp_enqueue_style('jquery.lightbox.css', JQLB_STYLE_URL, false, '1.1');
42
  }
43
  function jqlb_js() {
44
  if(is_admin() || is_feed()){return;}
45
  wp_deregister_script('jquery');
46
  wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js');
47
  wp_enqueue_script('jquery', '', array(), '1.4.2', true);
48
- wp_enqueue_script('wp-jquery-lightbox', JQLB_SCRIPT_URL, Array('jquery'), '1.1', true);
49
  wp_localize_script('wp-jquery-lightbox', 'JQLBSettings', array(
50
  'fitToScreen' => get_option('jqlb_resize_on_demand'),
51
  'resizeSpeed' => get_option('jqlb_resize_speed')
@@ -61,13 +61,13 @@ function jqlb_autoexpand_rel_wlightbox($content) {
61
  $replacement = '$1 rel="lightbox['.$post->ID.']">';
62
  $content = preg_replace($pattern, $replacement, $content);
63
  }
64
- return '<!-- wp-jquery-lightbox, a WordPress plugin by ulfben --> ' . $content;
65
  }
66
  function jqlb_pos_intval($v){
67
  return abs(intval($v));
68
  }
69
  function jqlb_options_panel(){
70
- if(function_exists('current_user_can') && !current_user_can('manage_options')){
71
  die(__('Cheatin&#8217; uh?'));
72
  } ?>
73
  <div class="wrap">
@@ -104,16 +104,16 @@ function jqlb_options_panel(){
104
  </form>
105
  <h2>How to Use:</h2>
106
  <ol>
107
- <li>Add a <code>rel="lightbox"</code> attribute to any link tag to activate the lightbox. For example:
 
108
  <pre><code> &lt;a href=&quot;images/image-1.jpg&quot; rel=&quot;lightbox&quot; title=&quot;my caption&quot;&gt;image #1&lt;/a&gt;</code></pre>
109
- <em>Optional: </em>Use the <code>title</code> attribute if you want to show a caption.
110
  </li>
111
  <li>If you have a set of related images that you would like to group, follow step one but additionally include a group name in the rel attribute. For example:
112
  <pre><code> &lt;a href=&quot;images/image-1.jpg&quot; rel=&quot;lightbox[roadtrip]&quot;&gt;image #1&lt;/a&gt;
113
  &lt;a href=&quot;images/image-2.jpg&quot; rel=&quot;lightbox[roadtrip]&quot;&gt;image #2&lt;/a&gt;
114
  &lt;a href=&quot;images/image-3.jpg&quot; rel=&quot;lightbox[roadtrip]&quot;&gt;image #3&lt;/a&gt;</code></pre>
115
- No limits to the number of image sets per page or how many images are allowed in each set. Go nuts!</li>
116
- <li>You can safely use WordPress image galleries and have them grouped and auto-lightboxed: <code>[gallery link="file"]</code></li>
117
  </ol>
118
 
119
  <h2>Credits</h2><ul style="list-style-type: circle;margin-left: 24px;">
@@ -123,12 +123,14 @@ function jqlb_options_panel(){
123
  <li><a href="http://github.com/krewenki/jquery-lightbox/">jQuery Lightbox</a> is based on <a href="http://www.huddletogether.com/projects/lightbox2/">Lightbox 2 by Lokesh Dhakar</a></li>
124
  </ul>
125
 
126
- <h2>Notes to self:</h2><p style="margin-left: 24px;">
127
  I've changed the behaviour of jQuery Lightbox to rely on <code>rel="lightbox"</code> instead of <code>class="lightbox"</code>, since rel is what all the previous *box-scripts used.<br />
128
  I rewrote the jQuery Lightbox resizing code, to take into account <strong>both</strong> height and width and never destroy aspect ratio.<br />
129
  I replaced the <code>fileLoadingImage</code>-setting with a <code>jqlb_loading</code>-div, feeding an image from CSS instead of parameterizing the javascript.<br />
130
  I did the same thing with <code>fileBottomNavCloseImage</code> (replaced with <code>jqlb_closelabel</code>-div)<br />
131
  I borrowed the regular expression from LightBox-2, to automatically insert rel="lightbox[post_id]" without clobbering manual inputs.<br />
 
 
132
  </p>
133
  </div>
134
  <?php } ?>
3
  Plugin Name: wp-jquery-lightbox
4
  Plugin URI: http://wordpress.org/extend/plugins/wp-jquery-lightbox/
5
  Description: A drop in replacement for LightBox-2 and similar plugins. Uses jQuery to save you from the JS-library mess in your header. :)
6
+ Version: 1.2
7
  Author: Ulf Benjaminsson
8
  Author URI: http://www.ulfben.com
9
  */
14
  define('WP_PLUGIN_URL', WP_CONTENT_URL.'/plugins');
15
  }
16
  define('JQLB_URL', WP_PLUGIN_URL.'/wp-jquery-lightbox/');
17
+ define('JQLB_SCRIPT_URL', JQLB_URL.'jquery.lightbox.min.js');
18
+ define('JQLB_STYLE_URL', JQLB_URL.'lightbox.min.css');
19
  add_action('admin_menu', 'jqlb_register_menu_item');
20
  add_action('wp_print_styles', 'jqlb_css');
21
  add_action('wp_print_scripts', 'jqlb_js');
38
  }
39
  function jqlb_css(){
40
  if(is_admin() || is_feed()){return;}
41
+ wp_enqueue_style('jquery.lightbox.min.css', JQLB_STYLE_URL, false, '1.2');
42
  }
43
  function jqlb_js() {
44
  if(is_admin() || is_feed()){return;}
45
  wp_deregister_script('jquery');
46
  wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js');
47
  wp_enqueue_script('jquery', '', array(), '1.4.2', true);
48
+ wp_enqueue_script('wp-jquery-lightbox', JQLB_SCRIPT_URL, Array('jquery'), '1.2', true);
49
  wp_localize_script('wp-jquery-lightbox', 'JQLBSettings', array(
50
  'fitToScreen' => get_option('jqlb_resize_on_demand'),
51
  'resizeSpeed' => get_option('jqlb_resize_speed')
61
  $replacement = '$1 rel="lightbox['.$post->ID.']">';
62
  $content = preg_replace($pattern, $replacement, $content);
63
  }
64
+ return "\n<!-- wp-jquery-lightbox, a WordPress plugin by ulfben --> \n" . $content;
65
  }
66
  function jqlb_pos_intval($v){
67
  return abs(intval($v));
68
  }
69
  function jqlb_options_panel(){
70
+ if(!function_exists('current_user_can') || !current_user_can('manage_options')){
71
  die(__('Cheatin&#8217; uh?'));
72
  } ?>
73
  <div class="wrap">
104
  </form>
105
  <h2>How to Use:</h2>
106
  <ol>
107
+ <li>You can safely use WordPress image galleries and have them grouped and auto-lightboxed: <code>[gallery link="file"]</code></li>
108
+ <li>Alternatively, manually add a <code>rel="lightbox"</code> attribute to any link tag to activate the lightbox. For example:
109
  <pre><code> &lt;a href=&quot;images/image-1.jpg&quot; rel=&quot;lightbox&quot; title=&quot;my caption&quot;&gt;image #1&lt;/a&gt;</code></pre>
110
+ <em>Optional:</em> Use the <code>title</code> attribute if you want to show a caption.
111
  </li>
112
  <li>If you have a set of related images that you would like to group, follow step one but additionally include a group name in the rel attribute. For example:
113
  <pre><code> &lt;a href=&quot;images/image-1.jpg&quot; rel=&quot;lightbox[roadtrip]&quot;&gt;image #1&lt;/a&gt;
114
  &lt;a href=&quot;images/image-2.jpg&quot; rel=&quot;lightbox[roadtrip]&quot;&gt;image #2&lt;/a&gt;
115
  &lt;a href=&quot;images/image-3.jpg&quot; rel=&quot;lightbox[roadtrip]&quot;&gt;image #3&lt;/a&gt;</code></pre>
116
+ No limits to the number of image sets per page or how many images are allowed in each set. Go nuts!</li>
 
117
  </ol>
118
 
119
  <h2>Credits</h2><ul style="list-style-type: circle;margin-left: 24px;">
123
  <li><a href="http://github.com/krewenki/jquery-lightbox/">jQuery Lightbox</a> is based on <a href="http://www.huddletogether.com/projects/lightbox2/">Lightbox 2 by Lokesh Dhakar</a></li>
124
  </ul>
125
 
126
+ <h2>Notes to self:</h2><p style="margin-left: 24px;">
127
  I've changed the behaviour of jQuery Lightbox to rely on <code>rel="lightbox"</code> instead of <code>class="lightbox"</code>, since rel is what all the previous *box-scripts used.<br />
128
  I rewrote the jQuery Lightbox resizing code, to take into account <strong>both</strong> height and width and never destroy aspect ratio.<br />
129
  I replaced the <code>fileLoadingImage</code>-setting with a <code>jqlb_loading</code>-div, feeding an image from CSS instead of parameterizing the javascript.<br />
130
  I did the same thing with <code>fileBottomNavCloseImage</code> (replaced with <code>jqlb_closelabel</code>-div)<br />
131
  I borrowed the regular expression from LightBox-2, to automatically insert rel="lightbox[post_id]" without clobbering manual inputs.<br />
132
+ I've added support to grab titles and captions from the WordPress Media Gallery-output (<code>[gallery]</code>, "insert attachments" etc)<br />
133
+ I've fixed the bug of ignoring empty titles (now honored)
134
  </p>
135
  </div>
136
  <?php } ?>