Coding a lightbox in a plug in
leefish Offline
Hamster
*****
Posts: 1,009
Joined: Apr 2010
Post: #1
Coding a lightbox in a plug in
I am trying to make a template in a plug in that will cause a lightbox to open when the resulting inserted image is clicked on:

PHP Code:
1
2
3
4
5
6
7
8
9
10
11
{
   $text = $this->html($text);
	if($link != '')
          {
	return "<div class=\"wikiimage\"><a href=\"{$link}\" rel=\"lightbox\"><img src=\"{$url}\" alt=\"{$text}\" /></a><br />{$text}</div>\n";
           }
	else
	{
	return "<div class=\"wikiimage\"><img src=\"{$url}\" alt=\"{$text}\" /><br />{$text}</div>\n";
	}
}


however, this is not working for me. When I inspect element using firebug then I get this:

Code:
<a rel="lightbox" href="http://www.leefish.nl/mybb/wiki.php?file/how-to-make-ambtattoos/ambtattoo-tut-1.jpg"><img alt="" src="http://www.leefish.nl/mybb/wiki.php?file/how-to-make-ambtattoos/ambtattoo-tut-1.jpg"></a>


It should be

Code:
<a href="http://www.leefish.nl/mybb/wiki.php?file/how-to-make-ambtattoos/ambtattoo-tut-1.jpg" rel="lightbox" ><img alt="" src="http://www.leefish.nl/mybb/wiki.php?file/how-to-make-ambtattoos/ambtattoo-tut-1.jpg"></a>


How should I order the input in the php to make the lightbox code show correctly? At the moment when I click on the image it just opens in a new window, rather than in a lightbox.



[Image: leelink.gif]
MYBB1.6 & XThreads
08-19-2010 06:13 PM
Visit this user's website Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #2
RE: Coding a lightbox in a plug in
The order of attributes in tags does not matter, so it's possible Firebug is rearranging them.  If you want to check HTML output, you should use the View -> Source option (not sure if View Selection Source is reliable or not).

As for why Lightbox isn't working, it could be a script error on the page?  Enable the Firebug console and see if it comes up with errors.

My Blog
08-19-2010 06:45 PM
Find all posts by this user Quote this message in a reply
leefish Offline
Hamster
*****
Posts: 1,009
Joined: Apr 2010
Post: #3
RE: Coding a lightbox in a plug in
Thanks for the quick reply Zinga. I checked using view source and selection source and in both cases the HTML looked correct.

Code:
<div class="wikiimage"><a href="http://www.leefish.nl/mybb/wiki.php?file/how-to-make-ambtattoos/ambtattoo-tut-2.jpg" rel="lightbox"><img src="http://www.leefish.nl/mybb/wiki.php?file/how-to-make-ambtattoos/ambtattoo-tut-2.jpg" alt="" /></a><br /></div>


I have a hell of a lot of warnings on my page (yellow triangles) - mainly related to MYBB javascript, but no errors. I also have another lightbox running fine on the board - using that code, so it has to be something in the wiki tag set up.(I think).

I shall continue to nibble at it.



[Image: leelink.gif]
MYBB1.6 & XThreads
08-19-2010 08:52 PM
Visit this user's website Find all posts by this user Quote this message in a reply

« Next Oldest | Next Newest »

 Standard Tools
Forum Jump: