miniBB ®  
miniBB Support Forums
 | Forums | Register | Reply | Search | Statistics | Manual | miniBB Mobile
Custom Tutorials and Modifications miniBB Support Forums / Custom Tutorials and Modifications /   

implementing lightbox for viewing images ([imgs] & image gallery)

Author hubba
Guest
#1 | Posted: 21 Sep 2007 17:04 
hi there,

some of you might want to implement lightbox into minibb for replacing the standard javascript-popups when displaying [imgs]-images or pictures uploaded through the premium add-on "file attachments and automatic image Galleries"

thanks a lot to paul who helped me optimizing it through adding the values to bb_plugins.php.

here is what i did:

* download lightbox2
from http://www.huddletogether.com/projects/lightbox2/

* copy the folders
/js/, /images/ and /css/ to your minibb-directory

* edit bb_plugins.php
add this line somewhere in the code (preferable at the top):

/* lightbox implement */
if($action=='vthread'){
$lightboxjs=<<<out
<link rel="stylesheet" href="css/lightbox.css" type="text/css" media="screen" />
<script src="js/prototype.js" type="text/javascript"></script>
<script src="js/scriptaculous.js?load=effects" type="text/javascript"></script>
<script src="js/lightbox.js" type="text/javascript"></script>
out;
}
/* --lightbox implement */

* edit templates/main_header.html
add {$lightboxjs} somewhere between <head> and </head>


for use with [imgs]-tags:
* edit bb_codes.php
change your [imgs]-codes to:

enCodeBB:
/* [IMGS] tag code - with fixed width in lightbox */
$pattern[]="/\[imgs\](http:\/\/([^<> \n\r\[\]&]+?)\.?(gif|jpg|jpeg|png)?)\[\/imgs\]/i";
$replacement[]='<a href="\\1" target="" rel="lightbox"><img src="\\1" alt="" title="" style="width:'.$GLOBALS['imgsWidth'].'px" /></a>';

/* [IMGS] tag code - with fixed width and alt in lightbox */
$pattern[]="/\[imgs=(http:\/\/([^<> \n\r\[\]&]+?)\.?(gif|jpg|jpeg|png)?)\](.*?)\[\/imgs\]/i";
$replacement[]='<a href="\\1" title="\\4" target="" rel="lightbox"><img src="\\1" alt="\\4" title="\\4" style="width:'.$GLOBALS['imgsWidth'].'px" /></a>';

deCodeBB:
/* [IMGs] tag code - with fixed width in lightbox */
$pattern[]="/<a href=\"([^<> \n\r\[\]&]+?)\" target=\"\" rel=\"lightbox\">[ ]<img src=\"([^<> \n\r\[\]]+?)\" alt=\"\" (title=\"\" )?style=\"width:[0-9]+px\" \/><\/a>/i";
$replacement[]="[imgs]\\1[/imgs]";

/* [IMGS] tag code - with fixed width and alt in lightbox */
$pattern[]="/<a href=\"([^<> \n\r\[\]&]+?)\" title=\"(.+?)\" target=\"\"( rel=\"lightbox\")?>[ ]<img src=\"([^<> \n\r\[\]]+?)\" alt=\"(.+?)\" (title=\"(.+?)\" )?style=\"width:[0-9]+px\" \/><\/a>/i";
$replacement[]="[imgs=\\1]\\2[/imgs]";


using lightbox for the image galleries:
* edit bb_plugins.php
change the line containing $a1 into:
$a1="<a href=\"{$a1_url}\" rel=\"lightbox\" title=\"{$alt}\" onmouseover=\"window.status='{$nameJs}';return true;\" onmouseout=\"window.status='';return true;\">";


that's all
hope it works and you have fun with it

thanks again to paul, hope that it's okay to spread that tiny piece of code of your unbeatable fileupload-add-on.
to all minibblers out there: if you want to turn your board into some highly configurable imagegallery or file-storage, support the dev-team and buy their truly elegant piece of code which the add-on is. you won't regret it!
Author Paul
CEO
#2 | Posted: 22 Sep 2007 07:22 
Thank you for your support and posting this solution.

I hope it will be useful for those 'lightbox' fans! :-) I am myself do not like the principle of how this JS-script works, however I won't deny fashion is the power of the progress ;-)
Author Ccarriveau
Guest
#3 | Posted: 20 Oct 2007 22:57 
can you post "already-modified" versions of the files above?
In other words files that have already been changed to work?
Author Homie
Guest
#4 | Posted: 20 Oct 2007 22:59 
I'm interested in that too, but i'm not a heavy coder and would probably mess it up irreversibly.
posting the fixed files would be great!
Author Paul
CEO
#5 | Posted: 21 Oct 2007 11:30 | Edited by: Paul 
Ccarriveau
Homie

It's not necessary to post similar messages under different nicknames, if you are the same person. You won't achive anything that way ;-)

Start learning how to copy and paste the text. The instructions above are more than enough. Posting directly modified files is a fair job, because they could contain pieces of code for other add-ons as well.
Custom Tutorials and Modifications miniBB Support Forums / Custom Tutorials and Modifications / implementing lightbox for viewing images ([imgs] & image gallery) Top
Your Reply Click this icon to move up to the quoted message
 Short link for this topic:

 ?
You are welcome to post anonymously, by entering a nickname with no password (if the similar Username has not been taken yet), or by leaving both fields empty. If you have a forums account, you can also sign in from this page without posting a message, or sign in and post at once.


Before posting, make sure your message is compliant with our forum posting rules. If not, it may be locked or deleted with no explanation.

 
miniBB Support Forums Powered by Forum Software miniBB ® Features  Requirements  Demo  Download  Showcase  Gallery of Arts
Compiler  Premium Extensions  Premium Support  License  Contacts
  Organize opinions on miniBB-forums,
collecting them with the Polls & Surveys add-on!
Polls addon for miniBB