4images Forum & Community

4images Modifications / Modifikationen => Mods & Plugins (Releases & Support) => Topic started by: V@no on April 27, 2003, 06:14:08 AM

Title: [Mod] Add/Remove image to/from lightbox without page refresh (2009-07-29)
Post by: V@no on April 27, 2003, 06:14:08 AM
This little "fix" will do exactly what 4images has by default -> add/remove images to/from lightbox, BUT without whole page refresh.

Demo (http://4images.vano.org/ajaxcomments/) (you can login with any username/password you want)

Anyone who installed this mod before 2009-07-29 and having problem, please reinstall it, it was updated.

Step 1.
Open /includes/functions.php
Find:
Code: [Select]
     $lightbox_button = "<a href=\"".$site_sess->url($lightbox_url)."\"><img src=\"".get_gallery_image("lightbox_yes.gif")."\" border=\"0\" alt=\"\" /></a>";Replace with:
Code: [Select]
     $lightbox_button = "<a href=\"".$site_sess->url($lightbox_url)."\" onclick=\"this.firstChild.src='".$site_sess->url(ROOT_PATH."lightboxaction.php?id=".$image_row['image_id'])."&ilu='+this.firstChild.src; return false;\"><img src=\"".get_gallery_image("lightbox_yes.gif")."\" border=\"0\" alt=\"\" /></a>";

Step 1.2.
Few lines down, find:
Code: [Select]
     $lightbox_button = "<a href=\"".$site_sess->url($lightbox_url)."\"><img src=\"".get_gallery_image("lightbox_no.gif")."\" border=\"0\" alt=\"\" /></a>";Replace with:
Code: [Select]
     $lightbox_button = "<a href=\"".$site_sess->url($lightbox_url)."\" onclick=\"this.firstChild.src='".$site_sess->url(ROOT_PATH."lightboxaction.php?id=".$image_row['image_id'])."&ilu='+this.firstChild.src; return false;\"><img src=\"".get_gallery_image("lightbox_no.gif")."\" border=\"0\" alt=\"\" /></a>";

Step 2.
Create new file: lightboxaction.php
with this code:
Code: [Select]
<?php
define
('ROOT_PATH''./');
include(
ROOT_PATH.'global.php');
require(
ROOT_PATH.'includes/sessions.php');
$error 0;
if (isset(
$HTTP_GET_VARS['ilu']) || isset($HTTP_POST_VARS['ilu']))
{
  
$ilu = (isset($HTTP_POST_VARS['ilu'])) ? trim($HTTP_POST_VARS['ilu']) : trim($HTTP_GET_VARS['ilu']);
}
else
{
  
$ilu "";
}
if (
$id && $user_info['user_level'] >= USER)
{
  if (
check_lightbox($id))
  {
    
$ilu = (remove_from_lightbox($id)) ? get_gallery_image("lightbox_no.gif") : get_gallery_image("lightbox_yes.gif");
  }
  else
  {
    
$ilu = (add_to_lightbox($id)) ? get_gallery_image("lightbox_yes.gif") : get_gallery_image("lightbox_no.gif");
  }
}
else
{
  
$error 1;
}
if (
$error)
{
  die(
"Security violation");
}
header("Content-type: image/gif");
header("Location: ".$ilu);
?>
Upload it to your 4images root dir.

The only little "draw-back" in this method, that cursor will stay as default on non IE or NS6 browsers, when u put it over the lightbox image, because I had to remove "link" from that button.

P.S. if u installed "Lightbox for guests (http://www.4homepages.de/forum/index.php?topic=4826)" MOD, then u should remove && $user_info['user_level'] >= USER from Step 2.
Title: [Mod] Add/Remove image to/from lightbox without page refresh
Post by: Biggi on April 28, 2003, 11:30:42 AM
Hi V@no,

thanks for this mod! I'd really be glad if I'd have as much knowledge of PHP :wink:

Reading your article I had an idea and I was wondering if this would be possible:

I'd like to use ONE lightbox for all members. Lets call it for example "Gallerybox" or similar.

If someone likes a picture of another user very much, he could send it with a specific button (like that one for the user-lightboxes) to the Gallerybox to call on all other users to vote for it. The images that achieve best votes could be send to a special categorie with best voted images when a limited time is over.

What do you think about it? Would this be a challenge for you to code it and would it be very much difficult? I think this would be a mod that many,  many users love  :P

Regards,
Biggi
Title: [Mod] Add/Remove image to/from lightbox without page refresh
Post by: SLL on April 28, 2003, 12:53:15 PM
Quote from: Biggi
I'd like to use ONE lightbox for all members. Lets call it for example "Gallerybox" or similar.

global "lightbox" for all members called top.php  :lol:
Title: [Mod] Add/Remove image to/from lightbox without page refresh
Post by: Biggi on April 28, 2003, 02:02:41 PM
I know  :wink:

But thats not what I mean. In top.php there are the images with most votes, best ratings etc.

What I'm looking for is a possibility to let the users vote for my extra categorie "pictures of the month" (Bilder des Monats). If you like you can see it on my galery at http://www.hilfebullet.de/bibodia/4images/ on the top (right side). For this feature I have to find out on each end of a month which images are highly rated and show them by building a seperate page for each month.

Now we decided to have a poll each month about the highest rated 10 images to decide which 5 at least are the pics of the month.

My idea that I described here is to let the users decide, which images should take part at the poll.

I hope I did explain it well - my english doesn't rock after such a long time being out of school  :D
Title: Re: Add/Remove image to/from lightbox without page refresh
Post by: Chris on April 28, 2003, 04:21:56 PM
To avoid further confusion, I've deleted this post.

Please do not incorporate the previous javascript code I suggested.  It was untested and I shouldn't have posted it.  Sorry.  :oops:
Title: [Mod] Add/Remove image to/from lightbox without page refresh
Post by: HelpMeNow on April 29, 2003, 12:39:58 AM
V@no, I could kiss you for this mod!  :wink:

THANKSSSSSSSSSSSS more than million times. I really, really, really LOVE IT and NEEDED it!

Thanks again for a great wonderful MOD as usual.
Title: Re: Add/Remove image to/from lightbox without page refresh
Post by: V@no on April 29, 2003, 08:51:53 AM
Quote from: Chris
you can use this:
Code: [Select]
$lightbox_button = "<a href=\"javascript:void(0);\"><img onClick=\"this.src='lightboxaction.php?id=".$image_row['image_id']."&action='+this.src\" src=\"".get_gallery_image("lightbox_no.gif")."\" border=\"0\" alt=\"\" /></a>";
before I desided delete "link" I tryed your method, and for some reason, I was getting broken image, and no add/remove actions were taken...
it was some kind of JS conflict or something?
Title: [Mod] Add/Remove image to/from lightbox without page refresh
Post by: Chris on April 29, 2003, 03:46:48 PM
Yeah.  I thought of that about 30 minutes after making that post.  I haven't tested it and I think I know why it wouldn't work.  The click event would be captured by the <a> tag and not propagated to the onClick method in the <img> tag.

There should be a way to do it using the id attribute of the <img> tag and tying it to the <a> tag using javascript.  It would be something like
Code: [Select]
<a href="javascript:void(0);" onClick="document.lightboxBtn.src='lightboxaction.php?id=  ...'><img id="lightboxBtn" src="get_gallery_image()"/></a>
Mind you this is only a quick example and I'd have to actually play with it to come up with something that works but this is the general idea.
Title: [Mod] Add/Remove image to/from lightbox without page refresh
Post by: Lord Nite on May 02, 2003, 11:23:53 AM
Very well done V@no.

Once again, you provide a quality mod to the gallery users. :)
Title: [Mod] Add/Remove image to/from lightbox without page refresh
Post by: jackie911 on May 03, 2003, 07:38:18 PM
Small Bugs to my site.

Please help me to check it.

==> http://album.barndisco.com

Jackie
jackie911@so-net.com.hk
Title: [Mod] Add/Remove image to/from lightbox without page refresh
Post by: V@no on May 03, 2003, 08:23:47 PM
Quote from: jackie911
Small Bugs to my site.

Please help me to check it.

==> http://album.barndisco.com

Jackie
jackie911@so-net.com.hk
please read this:
http://www.4homepages.de/forum/index.php?topic=3914

Personaly I ignore post like this! :roll:
Title: [Mod] Add/Remove image to/from lightbox without page refresh
Post by: jackie911 on May 03, 2003, 08:28:09 PM
Thanks..............I know it.
Title: [Mod] Add/Remove image to/from lightbox without page refresh
Post by: V@no on May 03, 2003, 08:37:58 PM
Quote from: jackie911
Thanks..............I know it.

then, please, for the feature be more describing :roll:

about your small bug:
there is nothing wrong with the original script. The problem u have, is because u tryed to do changes that vividview posted, unfortunetly it doesnt work. So, for now just stick with the original script, with "onMouseOver" effect.
Title: [Mod] Add/Remove image to/from lightbox without page refresh
Post by: jackie911 on May 03, 2003, 09:48:12 PM
Thank you very much.

 :lol:
Title: [Mod] Add/Remove image to/from lightbox without page refresh
Post by: lutz on June 21, 2003, 07:13:41 PM
hi all,

this mod is really great, because it´s a madness to refresh the whole page reloading e.g. 40-60 images like some of my clients do!
but now, they are surprised at not seeing the thumbnail disappearing from the lightbox by deactivating the check mark...

well, if you change only step 1.2. you will have the advantages of both "worlds".
for me it´s perfect now!

sometimes less is more...  :wink:
Title: [Mod] Add/Remove image to/from lightbox without page refresh
Post by: V@no on June 21, 2003, 11:23:21 PM
Quote from: lutz
well, if you change only step 1.2. you will have the advantages of both "worlds".

yes, but this way has a side effect - it will refresh whole page if u add and then remove image from lightbox, being on categories page or details page.
Title: [Mod] Add/Remove image to/from lightbox without page refresh
Post by: lutz on June 22, 2003, 12:14:36 AM
hello v@no,
in principle you`re right, you have to balance the advantages about the disadvantages. but it´s definitely better than always refreshing...
actually uncheck the image staying on the same categories or details page does not refresh the page!
i can live very good with this compromise and can recommend it.
Title: Re: [Mod] Add/Remove image to/from lightbox without page refresh
Post by: vanish on March 12, 2005, 12:01:21 PM
How I can add "click sound" effect in this MOD when I click to lightbox?
Title: works [Mod] Add/Remove image to/from lightbox without page refresh
Post by: Vincent on April 07, 2005, 10:56:54 PM
in a first try
and it works perfect
Now i will need help to do this
http://www.4homepages.de/forum/index.php?topic=7273.0

sincerly
vincent
Title: Re: [Mod] Add/Remove image to/from lightbox without page refresh
Post by: Vincent on May 01, 2005, 01:26:57 PM
thats fun - after installing i got errors in file i did not touch

Code: [Select]
Parse error: parse error, unexpected $ in D:\web-data\foto.wombat.ch\http\includes\functions.php on line 1580

Warning: Cannot add header information - headers already sent by (output started at D:\web-data\foto.wombat.ch\http\includes\functions.php:1580) in D:\web-data\foto.wombat.ch\http\includes\sessions.php on line 85

Warning: Cannot add header information - headers already sent by (output started at D:\web-data\foto.wombat.ch\http\includes\functions.php:1580) in D:\web-data\foto.wombat.ch\http\includes\sessions.php on line 85

Warning: Cannot add header information - headers already sent by (output started at D:\web-data\foto.wombat.ch\http\includes\functions.php:1580) in D:\web-data\foto.wombat.ch\http\includes\sessions.php on line 85

Fatal error: Call to undefined function: get_categories() in D:\web-data\foto.wombat.ch\http\index.php on line 67


what it means?
the first error on the list is just the end of the file!

vincent
Title: Re: [Mod] Add/Remove image to/from lightbox without page refresh
Post by: V@no on May 01, 2005, 07:42:59 PM
u've missed a bracket or something like that in functions.php
restore backups and try again ;)
Title: Re: [Mod] Add/Remove image to/from lightbox without page refresh
Post by: Vincent on May 14, 2005, 11:43:33 PM
i am going MAD i can't find something - but it is also not that easy like a html structure
the link to my functions.php file

http://www.foto-kocher.com/muster/functions.php.txt

and i hope somebody could see the missing thing!?

sincerly
vincent
Title: Re: [Mod] Add/Remove image to/from lightbox without page refresh
Post by: Vincent on May 19, 2005, 10:27:33 AM
did somebody find a mistak in the code?

i am going MAD i can't find something - but it is also not that easy like a html structure
the link to my functions.php file

http://www.foto-kocher.com/muster/functions.php.txt

and i hope somebody could see the missing thing!?

sincerly
vincent
Title: Re: [Mod] Add/Remove image to/from lightbox without page refresh
Post by: V@no on May 19, 2005, 02:18:24 PM
there is nothing wrong with the file, I dont get that error message. Perhaps something went wrong when u uploaded it? like it was uploaded in binary mode.
Title: Re: [Mod] Add/Remove image to/from lightbox without page refresh
Post by: Vincent on May 19, 2005, 03:39:09 PM
V@no
thanks a lot! but as soon as i uncoment the [mod] and coments the other line -  it crashes and it makes error!
sincerly
vincent
Title: Re: [Mod] Add/Remove image to/from lightbox without page refresh
Post by: V@no on May 19, 2005, 04:18:27 PM
are u saing u showed the "working" version of functions.php??? why would u do that? :?
Title: Re: [Mod] Add/Remove image to/from lightbox without page refresh
Post by: Vincent on May 21, 2005, 05:40:44 PM
this is the versin with the code added which is doing no error anymore
http://www.foto-kocher.com/muster/functions.php.txt

but still refreshs after selecting a picture?

vincent
Title: Re: [Mod] Add/Remove image to/from lightbox without page refresh
Post by: V@no on May 21, 2005, 05:51:54 PM
this is the versin with the code added which is doing no error anymore
I think u do something wrong ;)
I dont see any changes from this mod...
Title: Re: [Mod] Add/Remove image to/from lightbox without page refresh
Post by: Vincent on May 23, 2005, 11:13:43 PM
 :oops: sorry i copyed the wrong file first and second i have done the mod saved but the saving was not puting them back to the server - still hoping to learn to use macromedia Dreamwaver MX
http://www.foto-kocher.com/muster/functions.php.txt
the original code is // and just below or after ist the new active code

Code: [Select]
Parse error: parse error, unexpected $ in D:\web-data\foto.wombat.ch\http\includes\functions.php on line 1580

Warning: Cannot add header information - headers already sent by (output started at D:\web-data\foto.wombat.ch\http\includes\functions.php:1580) in D:\web-data\foto.wombat.ch\http\includes\sessions.php on line 85

Warning: Cannot add header information - headers already sent by (output started at D:\web-data\foto.wombat.ch\http\includes\functions.php:1580) in D:\web-data\foto.wombat.ch\http\includes\sessions.php on line 85

Warning: Cannot add header information - headers already sent by (output started at D:\web-data\foto.wombat.ch\http\includes\functions.php:1580) in D:\web-data\foto.wombat.ch\http\includes\sessions.php on line 85

Fatal error: Call to undefined function: get_categories() in D:\web-data\foto.wombat.ch\http\index.php on line 67
Title: Re: [Mod] Add/Remove image to/from lightbox without page refresh
Post by: V@no on May 24, 2005, 12:30:46 AM
the error doesnt comming from this mod, your check_lightbox function is messed up.
Title: Re: [Mod] Add/Remove image to/from lightbox without page refresh
Post by: Vincent on May 24, 2005, 08:07:36 AM
V@no
thanks for this info - could you tell me how to clean the check_lightbox function! or should this be a new topic?
the funny part is "unexpected $ in D:\web-data\foto.wombat.ch\http\includes\functions.php on line 1580" line 1580 is absolut the closing part of the function.php

sincerly
vincent
Title: Re: [Mod] Add/Remove image to/from lightbox without page refresh
Post by: V@no on May 24, 2005, 02:39:47 PM
as I said, the error has nothing to do with this mod. U do something wrong somewhere else in functions.php
I have no clue why u even touching that check_lightbox function.
My suggestion is restore backups and try again.
Title: Re: [Mod] Add/Remove image to/from lightbox without page refresh
Post by: Vincent on May 24, 2005, 10:57:39 PM
V@no
i know what you mean with restoring backups - as you could test it works no without mod  - but if you log in and add a picture no problems are, exprect the page refreshs! this is how it works now - if i add the code i have the above errors!

sincerly
vincent
Title: Re: [Mod] Add/Remove image to/from lightbox without page refresh
Post by: V@no on May 24, 2005, 11:58:13 PM
if i add the code i have the above errors!
I really have no clue how u can get that error by adding the code from this mod...
change editor maybe?
seriosly, the error is comming from the part of the file absolutely not related to the code u are supposed to change acording to this mod...
perhaps its comming from "lightbox for guests" mod, but then why do we discuss it here, under this thread? ;)
Title: Re: [Mod] Add/Remove image to/from lightbox without page refresh
Post by: Vincent on July 25, 2005, 11:33:03 PM
V@no
now it works also on my page - the only point is - sincer the mod is running it is not telling sombody to register to use the lightbox!
bevor the MOD when sombody would add to the lightbox and was not registerd it failled and a information came!

could you tell me how to got the error information back?

sincerly
vincent
Title: Re: [Mod] Add/Remove image to/from lightbox without page refresh
Post by: V@no on July 26, 2005, 12:56:00 AM
sincer the mod is running it is not telling sombody to register to use the lightbox!
bevor the MOD when sombody would add to the lightbox and was not registerd it failled and a information came!

could you tell me how to got the error information back?
There is no such thing in default 4images behavour. By default lighbox button is greyed-out and not clickable, so u must be refering to some other code...
Title: Re: [Mod] Add/Remove image to/from lightbox without page refresh
Post by: Steel Rat on September 04, 2005, 08:45:39 AM
Hi V@no,

Just tried this mod and am getting unexpected results. This is a pretty simple mod to add so I'm pretty sure I didn't screw it up.

Anyway. With Firefox 1.0.6, the lightbox image never changes when clicked. Then if I got to my lightbox, a bunch of stuff has been added, seemingly randomly.

In IE 6 the response is a little different on the surface. Clicking a lightbox button the first time seems to have no effect. If I click the same one a second time the checked mark shows up. Going to my lightbox again shows a bunch of other stuff added to the lightbox.

Any thoughts?

Thanks.

SR
Title: Re: [Mod] Add/Remove image to/from lightbox without page refresh
Post by: Steel Rat on September 10, 2005, 06:17:16 AM
Will it be possible to receive some assistance on this?
Title: Re: [Mod] Add/Remove image to/from lightbox without page refresh
Post by: Steel Rat on September 26, 2005, 05:39:11 PM
I guess not... :cry:
Title: Re: [Mod] Add/Remove image to/from lightbox without page refresh
Post by: V@no on September 27, 2005, 12:07:14 AM
can I see it in action?
Title: Re: [Mod] Add/Remove image to/from lightbox without page refresh
Post by: Steel Rat on October 18, 2005, 11:41:35 PM
can I see it in action?

Only if we can coordinate a time. I don't want to leave the mod in place since it doesn't work right for me.
Title: Re: [Mod] Add/Remove image to/from lightbox without page refresh
Post by: fgallery on October 19, 2005, 11:07:53 AM
Just tried this mod and am getting unexpected results. This is a pretty simple mod to add so I'm pretty sure I didn't screw it up.
Anyway. With Firefox 1.0.6, the lightbox image never changes when clicked. Then if I got to my lightbox, a bunch of stuff has been added, seemingly randomly.
In IE 6 the response is a little different on the surface. Clicking a lightbox button the first time seems to have no effect. If I click the same one a second time the checked mark shows up. Going to my lightbox again shows a bunch of other stuff added to the lightbox.
Any thoughts?

Works fine for me with:
Mozilla/5.0 (Windows; U; Windows NT 5.2; ru-RU; rv:1.7.10) Gecko/20050717 Firefox/1.0.6
IE 6.0.3790.1830
Opera 8.5 (Build    7700; Win32;Windows NT 5.2)

And I also don't have the 'draw-back' Vano described.
Title: Re: [Mod] Add/Remove image to/from lightbox without page refresh
Post by: Ch*yeuk on July 25, 2006, 12:55:02 AM
Awesome! I was really annoyed that I had to keep pressing back to go back to the previous page when my clickstream didn't go to the right page. Not only that, but I had to press back twice.. for some reason. Anyways, glad this mod exists. Installed it, working perfectly, loving it =D The "draw-back" also doesn't occur for me.. or I misunderstood what you meant.
Title: Re: [Mod] Add/Remove image to/from lightbox without page refresh
Post by: pixelsmith on July 27, 2006, 03:55:12 PM
Dear Fans,
this MOD  will run with the actual version 1.7.3.

greetings
Title: Re: [Mod] Add/Remove image to/from lightbox without page refresh
Post by: BlackGoat on April 06, 2007, 11:15:06 AM
For everyone's info: this MOD works on version 1.7.4
Title: Re: [Mod] Add/Remove image to/from lightbox without page refresh
Post by: MaveriC on June 20, 2007, 01:54:22 PM
works perfectly on 1.7.4! way to go vano!  :)
Title: Re: [Mod] Add/Remove image to/from lightbox without page refresh
Post by: Jan-Lukas on February 05, 2009, 08:31:39 PM
thank you,
läuft auch unter 1.7.6 + Multi-Lightboxes v1.03 perfect

LG Harald
Title: Re: [Mod] Add/Remove image to/from lightbox without page refresh
Post by: Sun on April 09, 2009, 12:09:36 PM
Multi-Lightboxes v1.03 perfect

It's work. But dropdown menu is not refresh.
Title: Re: [Mod] Add/Remove image to/from lightbox without page refresh
Post by: bernd on July 29, 2009, 02:39:14 PM
I have a weird problem and I can't seem to be able to get my head around it:

I moved servers, on the old server everything was working perfectly. Now on the new server this MOD works on the detail page flawlessly but on the thumbnail view (either category, lightbox or search result) it doesn't. When I click on the lightbox button it "replaces" the image with a broken image and the image is not added/removed from the lightbox.
I didn't change a think in the configuration and all images are where they are supposed to be. Anyone had that before? Any idea what to look for?
I checked with Firebug / JavaScript console but no errors popped up.

If you want to take a look yourself go to http://www.bildagentur-hamburg.com/hh/ – you will need to be registered though.

Any feedback would be appreciated!

cheers,
Bernd
Title: Re: [Mod] Add/Remove image to/from lightbox without page refresh
Post by: V@no on July 29, 2009, 04:58:55 PM
There is something strange going on on your site with this mod...the reason its showing broken image is because it send thum_id instead of id. I don't know what else you've changed in the code, but I suggest you reinstall this mod. Actually I suggest reinstall it because I just updated it to make more compatible for clients with javascript turned off and for new 4images that filters out slashes from $action.

Anyone who installed this mod before 2009-07-29 and having problem, please reinstall it.
Title: Re: [Mod] Add/Remove image to/from lightbox without page refresh (2009-07-29)
Post by: mawenzi on July 29, 2009, 06:16:56 PM
... V@no, thanks for the update ...
... works perfectly again ...
Title: Re: [Mod] Add/Remove image to/from lightbox without page refresh
Post by: bernd on July 29, 2009, 08:50:23 PM
There is something strange going on on your site with this mod...the reason its showing broken image is because it send thum_id instead of id. I don't know what else you've changed in the code, but I suggest you reinstall this mod.
Yeah - true. I did enhance it as I use different "Lightbox" image for the thumbnail view. What stroke me is that it did work on the old server.

And now – tadaaaa – I fixed it (sorry, no Voodoo). Apparently the old server had "register_globals" activated, the new one does not and I did not use $_GET['thumb_id'] but directly $thumb_id ... changed, now it works.

Sorry for the trouble but thanks a bunch for the code update V@no – it's appreciated!

cheers,
bernd
Title: Re: [Mod] Add/Remove image to/from lightbox without page refresh (2009-07-29)
Post by: Mariuz on August 06, 2009, 03:42:38 PM
Working perfect..
thx  :D
Title: Re: [Mod] Add/Remove image to/from lightbox without page refresh (2009-07-29)
Post by: alekseyn1 on February 06, 2010, 04:48:29 PM
Not sure why, but i get a broken image as well... my system is based on 1.7.7 but hacked and modded heavily... BUT i did not touch the lightbox functions at all.... can anybody hint me about the error (I am not knowledgeable in JavaScript)...

login - tester
pw - tester
Title: Re: [Mod] Add/Remove image to/from lightbox without page refresh (2009-07-29)
Post by: Lucifix on April 06, 2010, 10:18:44 PM
@v@no: on my site for adding image to lightbox I'm not using images but text. And because your javascript check first src sure it's not working. Do you have any idea how to modify this?

Example:
Code: [Select]
      $lightbox_button = "<a href=\"".$site_sess->url($lightbox_url)."\" onclick=\"this.firstChild.src='".$site_sess->url(ROOT_PATH."lightboxaction.php?id=".$image_row['image_id'])."&ilu='+this.firstChild.src; return false;\">Add to lightbox</a>";
      $lightbox_button = "<a href=\"".$site_sess->url($lightbox_url)."\" onclick=\"this.firstChild.src='".$site_sess->url(ROOT_PATH."lightboxaction.php?id=".$image_row['image_id'])."&ilu='+this.firstChild.src; return false;\">Remove from lightbox</a>";
Title: Re: [Mod] Add/Remove image to/from lightbox without page refresh (2009-07-29)
Post by: Jan-Lukas on May 02, 2010, 10:32:03 PM

läuft auch unter 1.7.7 + Multi-Lightboxes v1.03 perfect

LG Harald
Title: Re: [Mod] Add/Remove image to/from lightbox without page refresh (2009-07-29)
Post by: Sebas Bonito on June 24, 2010, 01:55:38 PM
The graphic-version works fantastic, BUT...

...instead of the graphic-buttons I do only use text-buttons in the functions.php:

Code: [Select]
$lightbox_button = "<a href=\"".$site_sess->url($lightbox_url)."\" title=\"a favourite Picture.\" class=\"button_active\" >Lightbox</a>";and
Code: [Select]
$lightbox_button = "<a href=\"".$site_sess->url($lightbox_url)."\" title=\"not a favourite Picture yet.\" class=\"button\">Lightbox</a>";
The difference is just the background-color, which is given by the css-class "button" / "button_active".

So how to change (I guess the lightboxaction.php) to change only the backgroundcolor or the class after click the link?

Thanx!
Title: Re: [Mod] Add/Remove image to/from lightbox without page refresh (2009-07-29)
Post by: V@no on June 24, 2010, 02:33:25 PM
Sorry, in current version without rewriting javascript and the output script is not possible.
Title: Re: [Mod] Add/Remove image to/from lightbox without page refresh (2009-07-29)
Post by: zakaria666 on July 31, 2010, 08:39:58 PM
hi sir,

in alot of the great MODS ive been searching are in german and i dont speak german sir, are there alternative ways to do the great MODS made by people like remembrant who write in german. Because i feel a bit left out as i want to add alot of these mods but cannot :-(
Title: Re: [Mod] Add/Remove image to/from lightbox without page refresh (2009-07-29)
Post by: V@nо on July 31, 2010, 08:44:20 PM
1) we have page translation tool on the top of each page.
2) what was the point on asking this question under this mod, which is in english?
Title: Re: [Mod] Add/Remove image to/from lightbox without page refresh (2009-07-29)
Post by: zakaria666 on July 31, 2010, 09:53:56 PM
sorry, i do apologize i will dlete the comment i made
Title: Re: [Mod] Add/Remove image to/from lightbox without page refresh (2009-07-29)
Post by: bernd on January 23, 2011, 06:02:33 PM
The graphic-version works fantastic, BUT...
...instead of the graphic-buttons I do only use text-buttons in the functions.php:
[..]
The difference is just the background-color, which is given by the css-class "button" / "button_active".

I had the same "issue" and here I how I did it. I actually ended up doing it all in jQuery as I use on the site anyway. So there you go. my button code in functions.php looks like this

$lightbox_button = "<div class=\"lightbox\"><a href=\"".$site_sess->url($lightbox_url)."\" id=\"img".$image_row['image_id']."\" class=\"icon-tip\" title=\"".$lang['alt_lightbox_no']."\">".$lang['lightbox']."</a></div>";

and

$lightbox_button = "<div class=\"lightbox\"><a href=\"".$site_sess->url($lightbox_url)."\" id=\"img".$image_row['image_id']."\" class=\"icon-tip\" title=\"".$lang['alt_lightbox_yes']."\">".$lang['lightbox']."</a></div>";

This is slightly different from the standard set-up but you'll be able to spot the differences. I put the image-ID concatenated with "img" inside the id attribute as I will use jQuery to change this element's title attribute later on and finding this element I could only get to work using the id. Putting the "img" in front of the id itself is because an id should not start with a number. This lightbox link works as is also without jQuery.
This is the jQuery code (mine actually is slightly different as I also toggle a parent's <li> class)

Code: [Select]
$(document).ready(function() {
$('li div.lightbox a').click(function() {
var elementId = '#'+$(this).attr('id');
$.get(
"lightboxaction.php",
{ id: $(this).attr('id') },
function(data) {
$(elementId).attr('title', data);
},
"text");
return false;
});
});

I put this code into the footer.html. And then of course my lightboxaction.php

<?php
define('ROOT_PATH', './');
include(ROOT_PATH.'global.php');
require(ROOT_PATH.'includes/sessions.php');
$error = 0;
if (isset($HTTP_GET_VARS['id']) || isset($HTTP_POST_VARS['id']))
{
  $id = (isset($HTTP_POST_VARS['id'])) ? substr(trim($HTTP_POST_VARS['id']), 3) : substr(trim($HTTP_GET_VARS['id']), 3);
}
else
{
  $id = "";
}
if ($id)
{
  if (check_lightbox($id))
  {
    $title = (remove_from_lightbox($id)) ? $lang['alt_lightbox_no'] : $lang['alt_lightbox_yes'];
  }
  else
  {
    $title = (add_to_lightbox($id)) ? $lang['alt_lightbox_yes'] : $lang['alt_lightbox_no'];
  }
}
else
{
  $error = 1;
}
if ($error)
{
  die("Security violation");
}
echo $title;
?>

So to the previous question, it would be very easy to adopt it. Just change the jQuery code to the following. This should work and toggle your two classes on and off.

Code: [Select]
$(document).ready(function() {
$('li div.lightbox a').click(function() {
var elementId = '#'+$(this).attr('id');
$.get(
"lightboxaction.php",
{ id: $(this).attr('id') },
function(data) {
$(elementId).attr('title', data);
},
"text");
$(this).toggleClass('button');
$(this).toggleClass('button_active');
return false;
});
});

Oh - and of course you guys need to adopt the jQuery selector for the "click" to your needs. So the
Code: [Select]
$('li div.lightbox a').click(function() {needs to match your document's structure.

Yes, I agree - this is not a nice copy+paste tutorial but it should allow you to adopt it to your needs if you know a bit jQuery. I mean, I managd to come up with this and I hardly know jQuery  8)

b.
Title: Re: [Mod] Add/Remove image to/from lightbox without page refresh (2009-07-29)
Post by: alekseyn1 on March 09, 2011, 01:38:39 PM
Well, for those of you that could not make the MOD work using V@no's code, here is ther reworked code based on above post from bernd

Place this in your header.html

Code: [Select]
<script type="text/javascript">
$(document).ready(function(){
$('#lb a').click(function() {
$.get(
"lightboxaction.php",
{ id: $(this).attr('id') },
function(data) {
$('#lb img').attr('src', data);
},
"text");
return false;
});

});
</script>

first line of the image button in functions.php

$lightbox_button = "<span id=\"lb\"><a href=\"".$site_sess->url(ROOT_PATH."lightboxaction.php")."\" id=\"".$image_row['image_id']."\" title=\"".$lang['alt_lightbox_yes']."\"><img src=\"".get_gallery_image("lightbox_yes.gif")."\" border=\"0\" alt=\"\" /></a></span>";

second line of the image button
$lightbox_button = "<span id=\"lb\"><a href=\"".$site_sess->url(ROOT_PATH."lightboxaction.php")."\" id=\"".$image_row['image_id']."\" title=\"".$lang['alt_lightbox_no']."\"><img src=\"".get_gallery_image("lightbox_no.gif")."\" border=\"0\" alt=\"\" /></a></span>";


content of lightboxaction.php in your root

<?php
define('ROOT_PATH', './');
include(ROOT_PATH.'global.php');
require(ROOT_PATH.'includes/sessions.php');
$error = 0;
if (isset($HTTP_GET_VARS['id']) || isset($HTTP_POST_VARS['id']))
{
  $id = (isset($HTTP_POST_VARS['id'])) ? $HTTP_POST_VARS['id'] : $HTTP_GET_VARS['id'];
}
else
{
  $id = "";
}

if ($id)
{
  if (check_lightbox($id))
  {
    $title = (remove_from_lightbox($id)) ? get_gallery_image("lightbox_no.gif") : get_gallery_image("lightbox_yes.gif");
  }
  else
  {
    $title = (add_to_lightbox($id)) ? get_gallery_image("lightbox_yes.gif") : get_gallery_image("lightbox_no.gif");
  }
}
else
{
  $error = 1;
}


if ($error)
{
  die("Security violation");
}
echo $title;
?>
Title: Re: [Mod] Add/Remove image to/from lightbox without page refresh (2009-07-29)
Post by: zhono on March 30, 2011, 12:20:12 PM
Well, for those of you that could not make the MOD work using V@no's code, here is ther reworked code based on above post from bernd

Thanks for that. It works great, except for one problem. It adds and removes the image you want, just like it should. But when I use it on the categories page or the home page, in thumbnail_bit, it changes the lightbox button image for every one on the page. So if I click one, they all change to the "checked" image. Same thing if I click to remove from the lightbox. They all change. Any way to fix that?
Title: Re: [Mod] Add/Remove image to/from lightbox without page refresh (2009-07-29)
Post by: alekseyn1 on March 30, 2011, 12:29:41 PM
But when I use it on the categories page or the home page, in thumbnail_bit, it changes the lightbox button image for every one on the page. So if I click one, they all change to the "checked" image. Same thing if I click to remove from the lightbox. They all change.

my code above is for the details page only... it needs to be modified to be used on categories page... no time right now... maybe someone will help sooner than me...

do you really need this for the categories page? Do you think your users will decide to put the image into the lightbox based on thumbnail only? This will also discourage them from rating and commenting your images as well
Title: Re: [Mod] Add/Remove image to/from lightbox without page refresh (2009-07-29)
Post by: zhono on March 30, 2011, 12:37:27 PM
I'm working on modifying the code myself, so if no one else has a solution, I'll post mine. I couldn't use v@no's original code because I use jquery, and it breaks his code. With the layout of my site, it makes sense to have a favorites/lightbox button under the thumbnails. I built a screensaver mod(to replace KurtW's old one) and I want to be able to quickly add images to the favorites for use as a screensaver.


*EDIT*

Okay, I got it on my own. Here's what I did.


lightboxaction.php - same as yours above
Code: [Select]
<?php
define
('ROOT_PATH''./');
include(
ROOT_PATH.'global.php');
require(
ROOT_PATH.'includes/sessions.php');
$error 0;
if (isset(
$HTTP_GET_VARS['id']) || isset($HTTP_POST_VARS['id']))
{
  
$id = (isset($HTTP_POST_VARS['id'])) ? substr(trim($HTTP_POST_VARS['id']), 3) : substr(trim($HTTP_GET_VARS['id']), 3);
}
else
{
  
$id "";
}
if (
$id)
{
  if (
check_lightbox($id))
  {
    
$title = (remove_from_lightbox($id)) ? get_gallery_image("lightbox_no.gif") : get_gallery_image("lightbox_yes.gif");
  }
  else
  {
    
$title = (add_to_lightbox($id)) ? get_gallery_image("lightbox_yes.gif") : get_gallery_image("lightbox_no.gif");
  }
}
else
{
  
$error 1;
}


if (
$error)
{
  die(
"Security violation");
}
echo 
$title;
?>


javascript in header
Code: [Select]
<script type="text/javascript">
$(document).ready(function() {
$('div.lightbox img').click(function() {
var elementId = '#'+$(this).attr('id');
$.get(
"lightboxaction.php",
{ id: $(this).attr('id') },
function(data) {
$(elementId).attr('src', data);
},
"text");
return false;
});
});
</script>


first line
Code: [Select]
 $lightbox_button = "<div class=\"lightbox\"><a href=\"".$site_sess->url($lightbox_url)."\"><img id=\"img".$image_row['image_id']."\" src=\"".get_gallery_image("lightbox_yes.gif")."\" border=\"0\" alt=\"\" /></a></div>";          }


second line
Code: [Select]
     $lightbox_button = "<div class=\"lightbox\"><a href=\"".$site_sess->url($lightbox_url)."\"><img id=\"img".$image_row['image_id']."\" src=\"".get_gallery_image("lightbox_no.gif")."\" border=\"0\" alt=\"\" /></a></div>";


Works in thumbnail_bit anywhere I want it to.
Title: Re: [Mod] Add/Remove image to/from lightbox without page refresh (2009-07-29)
Post by: ahmed_badawy on May 27, 2011, 11:33:38 AM
Not working Often , i tested the mod in my localhost and the demo , same problem

I record video by Adobe Captivate for your site and i tested the mod .. see the video in Attach

I hope to find a solution for this problem
Title: Re: [Mod] Add/Remove image to/from lightbox without page refresh (2009-07-29)
Post by: V@no on May 28, 2011, 05:00:51 AM
Works fine for me in FF4, IE9, Chrome, Opera. Perhaps either something wrong with your browser (try another one), or ... something wrong with your browser :)
Title: Re: [Mod] Add/Remove image to/from lightbox without page refresh (2009-07-29)
Post by: ahmed_badawy on May 28, 2011, 06:49:21 AM
Works fine for me in FF4, IE9, Chrome, Opera. Perhaps either something wrong with your browser (try another one), or ... something wrong with your browser :)

My browser Google Chrome last version 11.0.696.71 ,, and I will try it in Firefox 4.0.1.

Try your Chrome browser and click on any Specific lightbox 3 or 4 time and refresh the browser and go to lightbox page and try to add or remove the same image.

thank you for your time  :)


--edit--

Firefox 4.0.1 working great

I will try IE9 and IE8 and IE7


--edit--

All versions of IE working

I think the problem with Chrome


--edit--

Been confirmed from another computer with a Google Chrome browser

First is working normally and click on any Specific lightbox 4 to 6 times and is not gonna working anymore
Title: Re: [Mod] Add/Remove image to/from lightbox without page refresh (2009-07-29)
Post by: ahmed_badawy on May 29, 2011, 06:19:14 PM
Did you try it  :?: :?: :!:
Title: Re: [Mod] Add/Remove image to/from lightbox without page refresh (2009-07-29)
Post by: ahmed_badawy on June 01, 2011, 12:12:58 PM
Does anyone know where the problem is  :roll: :roll:
Title: Re: [Mod] Add/Remove image to/from lightbox without page refresh (2009-07-29)
Post by: ahmed_badawy on June 04, 2011, 05:18:02 AM
Awkward Silence  :lol:
Title: Re: [Mod] Add/Remove image to/from lightbox without page refresh (2009-07-29)
Post by: ahmed_badawy on July 07, 2011, 04:42:37 PM
Please anyone knows what I have to do

I'm given up  :(
Title: Re: [Mod] Add/Remove image to/from lightbox without page refresh (2009-07-29)
Post by: Rembrandt on July 07, 2011, 06:26:17 PM
Please anyone knows what I have to do
...
i think there is a specific chrome problem, how about if you ask in "Google Chrome Forum".

and please read this -> http://www.4homepages.de/forum/index.php?topic=3914.0#post_rule8

mfg Andi

Title: Re: [Mod] Add/Remove image to/from lightbox without page refresh (2009-07-29)
Post by: ahmed_badawy on July 08, 2011, 01:09:11 AM
Please anyone knows what I have to do
...
i think there is a specific chrome problem, how about if you ask in "Google Chrome Forum".

and please read this -> http://www.4homepages.de/forum/index.php?topic=3914.0#post_rule8

mfg Andi



ops  :oops: :oops:

I'm so so sorry about that

I didn't mean to break the rules