OK I've been trying to integrate with Lightbox (http://www.huddletogether.com/projects/lightbox/) so I can use it in conjunction with SSI for my frontpage.
Well I've got it working using the following edit:
Quote
array(
'tag' => 'img',
'type' => 'unparsed_content',
'content' => '<a href="$1" target="_blank" rel="lightbox"><img src="$1" width="256px" height="192px" border="0" /></a>',
'validate' => create_function('&$tag, &$data, $disabled', '$data = strtr($data, array('<br />' => ''));'),
'disabled_content' => '($1)',
),
but I now want to go a stage further and have it so if I type in
[img=group1]X.jpg[/img]
it produces
<a href="X.jpg" rel="lightbox[group1]" title="mytitle">image #1</a>
I think the answer could be found by looking at the quotes code in Subs.php, but its far to complicated for me to make any sense of. Has anyone got any ideas or even better the correct changes to the code?
Thanks to anyone who can help.
I'm still stuck on this, if anyone has any thoughts they would be much appreciated.
Well you've already got an array that can take optional variables, why not work with that one?
array(
'tag' => 'img',
'type' => 'unparsed_content',
'parameters' => array(
'alt' => array('optional' => true),
'width' => array('optional' => true, 'value' => ' width="$1"', 'match' => '(\d+)'),
'height' => array('optional' => true, 'value' => ' height="$1"', 'match' => '(\d+)'),
),
'content' => '<img src="$1" alt="{alt}"{width}{height} class="bbc_img" />',
'validate' => create_function('&$tag, &$data, $disabled', '$data = strtr($data, array(\'<br />\' => \'\'));'),
'disabled_content' => '($1)',
),
So try:
array(
'tag' => 'img',
'type' => 'unparsed_content',
'parameters' => array(
'alt' => array('optional' => true),
'group' => array('optional' => true),
'width' => array('optional' => true, 'value' => ' width="$1"', 'match' => '(\d+)'),
'height' => array('optional' => true, 'value' => ' height="$1"', 'match' => '(\d+)'),
),
'content' => '<a href="$1" target="_blank" rel="lightbox[{group}]"><img src="$1" alt="{alt}"{width}{height} class="bbc_img" /></a>',
'validate' => create_function('&$tag, &$data, $disabled', '$data = strtr($data, array(\'<br />\' => \'\'));'),
'disabled_content' => '($1)',
),
Then you want use it as [img group=group1]Image URL[/img] with the output HTML:
<a href="Image URL" target="_blank" rel="lightbox[group1]"><img src="Image URL" alt="" class="bbc_img" /></a>
With this code you can still even use the width, height and alt BBC code to define their values.
Thanks Rumbaar your a god!
I was hoping to integrate this into the Thumbnail Mod (http://custom.simplemachines.org/mods/index.php?mod=1067)
This is the code for the Thumbnail BBcode.
array(
'tag' => 'imgt',
'type' => 'unparsed_content',
'content' => '<a href="$1" target="_blank" rel="lightbox"><img src="$1" width="256px" height="192px" border="0" /></a>',
'validate' => create_function('&$tag, &$data, $disabled', '$data = strtr($data, array(\'<br />\' => \'\'));'),
'disabled_content' => '($1)',
),
);
which using your code I've adjusted to this;
array(
'tag' => 'imgt',
'type' => 'unparsed_content',
'parameters' => array(
'group' => array('optional' => true),
),
'content' => '<a href="$1" target="_blank" rel="lightbox[{group}]"><img src="$1" width="256px" height="192px" border="0" /></a>',
'validate' => create_function('&$tag, &$data, $disabled', '$data = strtr($data, array(\'<br />\' => \'\'));'),
'disabled_content' => '($1)',
),
But that just causes the IMGT BBcode to stop working.
Thanks for getting me this far!
You're welcome. Yes I was thinking later on, it would be best to use an alternate bbcode as this global change would affect any 'normal' use of the IMG tags.
So I'm not 100% sure, have you gotten a solution or still having issues?
I'm still having problems I'm afraid, I think its because I've added an parameters array.
I tried making my own thumbnail BBcode by using your code, removing the variable heights and putting in fixed ones. That just resulted in the forum loading as a blank page though.
This is what I think *should* work:
array(
'tag' => 'imgt',
'type' => 'unparsed_content',
'parameters' => array(
'group' => array('optional' => true,)
'title' => array('optional' => true, 'value' => ' {"$1"}', ')
),
'content' => '<a href="$1" target="_blank" {title} rel="lightbox[{group}]"><img src="$1" width="128px" height="96px" border="0" /></a>',
'validate' => create_function('&$tag, &$data, $disabled', '$data = strtr($data, array(\'<br />\' => \'\'));'),
'disabled_content' => '($1)',
),
Should that be working? or have I made a miss-take somewhere?
Thanks
What are you trying to do with:
'title' => array('optional' => true, 'value' => ' {"$1"}', ')
But if I think right, try:
array(
'tag' => 'imgt',
'type' => 'unparsed_content',
'parameters' => array(
'group' => array('optional' => true),
'title' => array('optional' => true),
),
'content' => '<a href="$1" target="_blank" title="{title}" rel="lightbox[{group}]"><img src="$1" width="256px" height="192px" class="bbc_img" /></a>',
'validate' => create_function('&$tag, &$data, $disabled', '$data = strtr($data, array(\'<br />\' => \'\'));'),
'disabled_content' => '($1)',
),
That code also results in the forum opening as a blank white page. As does any page with SSI on it.
It's probably easier if you have the time to just glace at the Lighbox 2.0 page (http://www.huddletogether.com/projects/lightbox2/) (skip down to Part 2: Activate). It explains how to use it in the first few paragraphs. What I'm trying to do is get all the options working and customizable.
He explains it far better than I can.
Thanks for all your help so far.
Well I added that bbcode to my SMF 2.x Subs.php array and was able to post an image with no issues on my 2.x test site. There must be alternate code in that page or I'm not sure of the issue with SSI.php pulling contents from the main forum in regards to this alter code.
It all works perfectly!
I must have done something wrong the first time. I don't get a blank page anymore and I solve the problem with the BBcode being shown instead of the output by putting the new modified IMGT code underneath the old one.
array(
'tag' => 'imgt',
'type' => 'unparsed_content',
'content' => '<a href="$1" target="_blank" rel="lightbox"><img src="$1" width="256px" height="192px" border="0" /></a>',
'validate' => create_function('&$tag, &$data, $disabled', '$data = strtr($data, array('<br />' => ''));'),
'disabled_content' => '($1)',
),
array(
'tag' => 'imgt',
'type' => 'unparsed_content',
'parameters' => array(
'group' => array('optional' => true),
'title' => array('optional' => true),
),
'content' => '<a href="$1" target="_blank" title="{title}" rel="lightbox[{group}]"><img src="$1" width="256px" height="192px" border="0" /></a>',
'validate' => create_function('&$tag, &$data, $disabled', '$data = strtr($data, array('<br />' => ''));'),
'disabled_content' => '($1)',
),
Thanks so much Rumbaar, There's no way I could have done that alone.
You're welcome. Though I'd still look to use a unique bbcode from any current ones you use. So the current one can be used separately to any new one you've created.
Thanks for the tip, but I only use that BBcode for that sort of thing anyway. I'll bare it in mind if I mess around with any other BBcode though :)
After upgrading to Beta 4 I had to reinstall this mod. I now can't get it to work however. The first bit of code:
array(
'tag' => 'imgt',
'type' => 'unparsed_content',
'content' => '<a href="$1" target="_blank" rel="lightbox"><img src="$1" width="256px" height="192px" border="0" /></a>',
'validate' => create_function('&$tag, &$data, $disabled', '$data = strtr($data, array('<br />' => ''));'),
'disabled_content' => '($1)',
),
works fine. However if I put in the second half my forum loads a blank white page. Has there been a change in beta 4 which has thrown this code off? Or is there a syntax error I've missed?
The complete code which was working is:
array(
'tag' => 'imgt',
'type' => 'unparsed_content',
'content' => '<a href="$1" target="_blank" rel="lightbox"><img src="$1" width="256px" height="192px" border="0" /></a>',
'validate' => create_function('&$tag, &$data, $disabled', '$data = strtr($data, array('<br />' => ''));'),
'disabled_content' => '($1)',
),
array(
'tag' => 'imgt',
'type' => 'unparsed_content',
'parameters' => array(
'group' => array('optional' => true),
'title' => array('optional' => true),
),
'content' => '<a href="$1" target="_blank" title="{title}" rel="lightbox[{group}]"><img src="$1" width="256px" height="192px" border="0" /></a>',
'validate' => create_function('&$tag, &$data, $disabled', '$data = strtr($data, array('<br />' => ''));'),
'disabled_content' => '($1)',
),
Thanks to anyone who can help, however small the contribution :)
Anyone got any ideas? It was such a great bit of code and I want to avoid having to roll back our whole site to pre-lightbox integration. Which I will have to do if I can't find a solution in the next week or so.
I've gone over it again and again but I just can't spot the problem. Is it just me who can't spot it or am I missing a blindingly obvious syntax error?
Quote from: General_Naga on September 10, 2008, 10:27:41 AM
After upgrading to Beta 4 I had to reinstall this mod. I now can't get it to work however. The first bit of code:
array(
'tag' => 'imgt',
'type' => 'unparsed_content',
'content' => '<a href="$1" target="_blank" rel="lightbox"><img src="$1" width="256px" height="192px" border="0" /></a>',
'validate' => create_function('&$tag, &$data, $disabled', '$data = strtr($data, array('<br />' => ''));'),
'disabled_content' => '($1)',
),
works fine. However if I put in the second half my forum loads a blank white page. Has there been a change in beta 4 which has thrown this code off? Or is there a syntax error I've missed?
The complete code which was working is:
array(
'tag' => 'imgt',
'type' => 'unparsed_content',
'content' => '<a href="$1" target="_blank" rel="lightbox"><img src="$1" width="256px" height="192px" border="0" /></a>',
'validate' => create_function('&$tag, &$data, $disabled', '$data = strtr($data, array('<br />' => ''));'),
'disabled_content' => '($1)',
),
array(
'tag' => 'imgt',
'type' => 'unparsed_content',
'parameters' => array(
'group' => array('optional' => true),
'title' => array('optional' => true),
),
'content' => '<a href="$1" target="_blank" title="{title}" rel="lightbox[{group}]"><img src="$1" width="256px" height="192px" border="0" /></a>',
'validate' => create_function('&$tag, &$data, $disabled', '$data = strtr($data, array('<br />' => ''));'),
'disabled_content' => '($1)',
),
Thanks to anyone who can help, however small the contribution :)
Do you still need help with this?
I don't see anything in there that would cause an error.
Thanks I did manage to solve it with the help of another site. If anyone interested the solution is here (http://www.smfhelper.info/forum/index.php/topic,3034.msg30432.html#msg30432)