• [Mod] Add/Remove image to/from lightbox without page refresh (2009-07-29) 5 0 5 1
Currently:  

Author Topic: [Mod] Add/Remove image to/from lightbox without page refresh (2009-07-29)  (Read 112684 times)

0 Members and 1 Guest are viewing this topic.

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Administrator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
This little "fix" will do exactly what 4images has by default -> add/remove images to/from lightbox, BUT without whole page refresh.

Demo (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" MOD, then u should remove && $user_info['user_level'] >= USER from Step 2.
« Last Edit: July 30, 2009, 07:10:29 AM by V@no »
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Biggi

  • Jr. Member
  • **
  • Posts: 74
    • View Profile
    • http://www.bibodia.de/
[Mod] Add/Remove image to/from lightbox without page refresh
« Reply #1 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

Offline SLL

  • Hero Member
  • *****
  • Posts: 585
    • View Profile
[Mod] Add/Remove image to/from lightbox without page refresh
« Reply #2 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:

Offline Biggi

  • Jr. Member
  • **
  • Posts: 74
    • View Profile
    • http://www.bibodia.de/
[Mod] Add/Remove image to/from lightbox without page refresh
« Reply #3 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

Offline Chris

  • 4images Moderator
  • 4images Guru
  • *****
  • Posts: 4.487
  • Did u ever stop to think and then forget to start?
    • View Profile
Re: Add/Remove image to/from lightbox without page refresh
« Reply #4 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:

Offline HelpMeNow

  • Jr. Member
  • **
  • Posts: 94
    • View Profile
[Mod] Add/Remove image to/from lightbox without page refresh
« Reply #5 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.

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Administrator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Add/Remove image to/from lightbox without page refresh
« Reply #6 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?
« Last Edit: March 09, 2005, 03:06:23 AM by Chris »
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Chris

  • 4images Moderator
  • 4images Guru
  • *****
  • Posts: 4.487
  • Did u ever stop to think and then forget to start?
    • View Profile
[Mod] Add/Remove image to/from lightbox without page refresh
« Reply #7 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.

Offline Lord Nite

  • Newbie
  • *
  • Posts: 43
    • View Profile
[Mod] Add/Remove image to/from lightbox without page refresh
« Reply #8 on: May 02, 2003, 11:23:53 AM »
Very well done V@no.

Once again, you provide a quality mod to the gallery users. :)

Offline jackie911

  • Newbie
  • *
  • Posts: 41
    • View Profile
[Mod] Add/Remove image to/from lightbox without page refresh
« Reply #9 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

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Administrator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
[Mod] Add/Remove image to/from lightbox without page refresh
« Reply #10 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:
« Last Edit: March 28, 2005, 02:17:43 PM by V@no »
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline jackie911

  • Newbie
  • *
  • Posts: 41
    • View Profile
[Mod] Add/Remove image to/from lightbox without page refresh
« Reply #11 on: May 03, 2003, 08:28:09 PM »
Thanks..............I know it.

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Administrator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
[Mod] Add/Remove image to/from lightbox without page refresh
« Reply #12 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.
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline jackie911

  • Newbie
  • *
  • Posts: 41
    • View Profile
[Mod] Add/Remove image to/from lightbox without page refresh
« Reply #13 on: May 03, 2003, 09:48:12 PM »
Thank you very much.

 :lol:

Offline lutz

  • Addicted member
  • ******
  • Posts: 1.675
    • View Profile
[Mod] Add/Remove image to/from lightbox without page refresh
« Reply #14 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:
Grüße, Lutz
kurze antworten sind nicht unhöflich gemeint, sondern effizient
short answers are not meant rude, but just efficient

 

Post your comments here