MyBB Central

Full Version: Ajax image popup
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14
If you want your images to open in an ajax popup here is how:

1. Download attachment.

2. Upload the files to your server:
a. Upload the images to your root/image directory.
b. Upload the lightbox.js to your root/jscripts directory.
c. Upload  lightbox.css to your root/ directory

3.  In your admincp edit the template "headerinclude".  You will add these 2 lines in your meta.

Code:
<link rel="stylesheet" href="lightbox.css" type="text/css" media="screen" />
<script type="text/javascript" src="jscripts/lightbox.js"></script>

4. Edit the template " postbit > postbit_attachments_thumbnails_thumbnail" you will get rid of the target="_blank" and also add rel="lightbox" to the anchor.

Finished code should be this:

Code:
<a href="attachment.php?aid={$attachment['aid']}" rel="lightbox"><img src="attachment.php?thumbnail={$attachment['aid']}" class="attachment" alt="" /></a>&nbsp;&nbsp;&nbsp;

Now the only drawback of this is when you don't allow guests to view attachments.  The ajax will popup indefinitely until clicked.  I will work on a fix for that.  For now you can go into your group and change it for  "Unregistered / Not Logged In" to allow download of attachments.

You can see working demo here:  

http://www.democracyforums.com/showthread.php?tid=2006
If you installed this please post here your site.
Please make sure to test this in Firefox, Opera, and IE after installation. If you are getting an error it may be an onload conflict. You may need to add to the body tag of template "Show Thread Templates > showthread" this code:


Check your body tag and look for an onload attribute. Example:
<body onload="MM_preloadImages(‘/images/menu_on.gif’)…;">
A quick fix to this problem is to append the initLightbox() to the onload attribute as so:
<body onload="MM_preloadImages(‘/images/menu_on.gif’)…;initLightbox()">
Thanx
thnx Smile
works really nice
useful, and a funny link too
Great work.
looking forward to this

Edit: Its not working for me. Images up just opening in a new window.
Check to make sure the body tag is altered.
Im confused as to what to look for and do.
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14
Reference URL's