Lightbox + FancyTooltips Bug Fix

Published Tuesday, July 25, 2006 @ 8:04 pm • 10 Responses

For those of us enjoying the stylish functionality of Lightbox or any of its many incarnations, images "magically" overlay the window and unfold, revealing navigational buttons, image count, and of course the image titles.

For those of us enjoying the stylish functionality of FancyTooltips or any of its many incarnations, title and alt attributes manifest as stylish displays of CSS brilliance.

However, for those of us employing both features, there is a potential JavaScript conflict. This conflict makes it impossible for Lightbox to display the contents of title attributes associated with images. Thus, if you are employing Lightbox (or one of its many variations) and FancyTooltips (or one of its many variations), image titles will be missing from your Lightbox-displayed images. If this is the case, everything else (nav buttons, number display, close button) will display properly, including the "fancy" tooltips. If this sounds like your situation — missing Lightbox titles — we have good news..

Fortunately, the "fix" for this "bug" is relatively simple. Before getting to that, it is important to explain two things: (1) cause of the conflict and (2) verification of the conflict. Keep in mind that we are attempting to extrapolate from several specific scenarios to many possible configurations. So, if this article fails to fix your specific setup, hopefully it will provide insight toward an individually deduced solution.

First, let's examine the cause of the conflict. Generally speaking, JavaScript-based tooltip enhancement involves replacing title and/or alt attributes with author-specified "hooks" that enable scripts to function. For example, the FancyTooltips script rewrites all title="" attributes as fancytooltip="", thereby enabling the FancyTooltips script to recognize and act upon such attributes exclusively.

The problem is that once all of the title="" attributes have been replaced with script-specific hooks, Lightbox no longer recognizes them, making it impossible to display their contents. Hence the mysteriously missing Lightbox titles. To verify this, use your browser's "Save Page As…" feature to save an offline copy1 of a page that uses both Lightbox and FancyTooltips (or any other similarly conflicting scripts). Then, examine the source code of the offline copy and look for title="" attributes replaced by fancytooltip="". If you find that the title and/or alt attributes have indeed been rewritten, read on for the fix!

The Fix

Now that you hopefully understand the nature of the dilemma, it is time to completely eliminate the conflict.

Open your lightbox.js file and scroll down to around line #333, searching for the following:

// if image is NOT part of a set..
if((imageLink.getAttribute('rel') == 'lightbox')){
	// add single image to imageArray
	imageArray.push(new Array(imageLink.getAttribute('href'), imageLink.getAttribute('title')));			
} else {
// if image is part of a set..
	// loop through anchors, find other images in set, and add them to imageArray
	for (var i=0; i<anchors.length; i++){
		var anchor = anchors[i];
		if (anchor.getAttribute('href') && (anchor.getAttribute('rel') == imageLink.getAttribute('rel'))){
			imageArray.push(new Array(anchor.getAttribute('href'), anchor.getAttribute('title')));
		}
	}
	imageArray.removeDuplicates();
	while(imageArray[imageNum][0] != imageLink.getAttribute('href')) { imageNum++;}
}

Now, near the end of the fourth line, replace title with fancytooltip. Then, likewise, near the end of the eleventh line, replace title with fancytooltip. You're done. Upload the file and check tooltips and Lightbox images. You should now be enjoying titles in your image popups and titles in your fancy tooltips. Note that this easy fix may be generalized to any set of similarly conflicting scripts. Simply determine the rewritten attributes by saving an offline copy and then search for & replace the offending values in the corresponding scripts.

This article is a work in progress. Please contribute any helpful information by leaving a comment below or via the Contact form. God Bless.

Footnotes

  • 1 In general, offline copies are very useful troubleshooting tools, as they represent the code after scripts have acted upon it, thereby offering a more accurate view of what the browser actually interprets.

Dialogue

10 Responses Jump to comment form

1Andrew

August 27, 2007 at 7:21 pm

Thanks for this fix. I implemented this into slimbox (lighter version of lightbox), which needed a slight bit of tweaking. Where it says link.title and el.title, remember to change these to link.getAttribute(’fancytooltip’) and el.getAttribute(’fancytooltip’).

2Perishable

August 28, 2007 at 8:29 am

Thank you for sharing this tweak, Andrew! There are quite a few people using Slimbox these days, so I am sure that visitors will find the information helpful. Heck, if I had the time, I would dig into Slimbox myself..

By the way, the artwork in the Gallery section of your site is totally inspiring. May I ask what software was used to create/style the 3D objects? And also, do you offer any of them as desktop wallpaper? I would love to download..

3Brett

December 5, 2007 at 9:08 am

Holy cow, this could be it. I have searched far and wide for this. Only thing is I’m using Thickbock, by Cody Lidnley.

If you could provide any insight on how to modify that script accordingly it would be fantastic

Thanks

4Perishable

December 5, 2007 at 11:59 am

I will look into it as soon as I can find the time.. I am currently in the process of switching servers, but will keep this on the list and report back here as soon as possible. Stay tuned..

5Brett

December 10, 2007 at 11:04 pm

Never mind trying to troubleshoot this. It’s not possible to do exactly what I want. I have figured out how to allow the title thru to thickbox with any tooltip script out there, but as soon as you do you get the FF regular tooltip as well, derived from the newly allowed title attrib. I want IE and FF to both show a fancy tooltip of my choosing, neither IE nor FF to show a regular tooltip, and the Lightbox/thickbox/etc. to show its caption. This does not appear to be possible. Any thoughts on this are welcome. I would also settle for a js tooltip that only worked in IE, then FF could just use the title attrib to do a regular tooltip, but I can’t find any such IE-only tooltips. Email included.

Thanks

6Perishable

December 10, 2007 at 11:10 pm

Brett,

I have been fighting a hellish battle myself lately, and may have missed your email due to a nightmarish round of server switching.. I suspect that several comments were lost, as well as a few emails (yours included). Please feel free to resend the email if necessary, and I will do my best to check it out.

Regards,
Jeff_

7PLZTK

October 18, 2008 at 5:38 am

Hi, I have had the problem that my light-box is positioned either near the bottom ofmy browser window in FF and at the top in IE, and I have read that many other users are having a similar problem.

Basically I wanted my light-box to appear just below the top of the browser window (dynamic to where the page is currently scrolled to…) in both IE and FF, but could not find a solution to this on the forums….

I looked through the JA and played about a bit and came up with a v-simple a solution - it is a bit of a “fudge” but it seems to work.

Locate the following line of code in the lightbox.js file:
var lightboxTop = arrayPageScroll[1] + (document.viewport.getHeight() / 40);

and change it to:
var lightboxTop = arrayPageScroll[1] + ((document.viewport.getHeight() / 100) + 50);

Like I say, its a bit of a “fudge”, but basically I divide the height by 100 (you can increase this to be safe - i.e. if you have an exceptionally long page). This division places the light-box at the top of the screen in FF and as the light-box is already at the top of the screen in IE it makes no difference as it cannot be moved up any higher in any case. I then add 50 to the current integer (the top of the browser window) pushing the light-box position down 50px so it is in the same position in both browsers (50px from the top off the browser window). This 50 integer value can be changed depending on how far you want to push your light-box down.

8Jeff Starr

October 19, 2008 at 2:38 pm

Thanks, PLZTK! That is some choice workaround methodology you’ve concocted. The next time I am working with Lightbox, I will see if I can add to or improve the technique. In the meantime, it is good to have this information available online for others to reference. Thanks for taking the time to share it with us! :)

9Max

February 19, 2009 at 10:48 am

I am having a similar problem as discussed, but I’m using the qTip tooltip and FancyBox image gallery (similar to light box). The problem I’ve encountered is qTip doesn’t change the title tag, but hijacks it, keeping FancyBox from displaying it.
I’ve tried tinkering with the code, and got it to halfway work, but now the qTip tooltip displays as well as the generic IE “tooltip”.
When you get a chance can you look these up and see if there is a workaround for them?
Thanks.

10Jeff Starr

February 21, 2009 at 7:52 pm

Will do, Max! ..Just as soon as I get a chance ;)

Subscribe to comments on this post


[ Comments are closed for this post. ]

If you have additional information, contact me.

← Previous post • Next post →

« Website Attack RecoveryNew Online Vector Drawing Tool »

Contact Perishable Press

  • Contact Jeff via form

Search Perishable Press

About Perishable Press

Perishable Press is the virtual playground of Jeff Starr — visionary, founder and lead developer of Monzilla Media, a small web and graphic design company in the lush desert oasis of Moses Lake, Washington. Perishable Press features articles and tutorials on many aspects of digital design..

Read more..

Perishable on Twitter

heading out of town on a photographic excursion. great way to break up the routine.

Perishable on Tumblr

Office painted a warmish/neutral off-white color. New 2.1...

Tue, 02 Feb 2010


New office digs..


Night view..


Potential..

Office painted a warmish/neutral off-white color. New 2.1 Altec/Lansing speakers for crisp, clear sound. Two new executive desks: one for computer biz and another workspace for drawing, painting, and other offline pursuits. And of course, a big, cushy black office chair to make it all sweet.

Quick Photoshop Reset

Tue, 19 Jan 2010

Very good Photoshop trick to know: If you hold down ALT+CTRL+SHIFT (Mac: CMD+OPT+SHIFT) while starting Photoshop you can reset all settings back to factory default. Very useful if you have problems with some tools or the interface. – http://bit.ly/4A5LJ5

Insane October

Sun, 01 Nov 2009

By far the most insane month of 2009, October included the following activities:

1st week: Trip to the East Coast, beginning with some business in Connecticut.

2nd week: East Coast trip continues with much pleasure in downtown Manhattan.

3rd week: Photo and art excursions with good friend visiting from Portland, OR.

4th week: Marathon book-editing and fine-tuning for Digging into WordPress.

Now that November is here, things remain busy, but I am hoping to get a chance to restore some balance and regain my equilibrium. Of course, the holidays are right around the corner..

Import Feeds to Facebook

Mon, 07 Sep 2009

Seems like a lot of misinformation and confusion out there on how to import and display your feeds on Facebook. Here is what worked for me:

1. In the lower left-hand corner of your Facebook account, click on “Applications” > “Notes”.

2. In the upper mid-right column, click on “Import a blog” in the “Notes Settings” panel.

3. In the “Import an External Blog” panel, enter your feed URL and check the little box.

4. Click the “Start importing” button and then click on “Confirm Import” on the preview page.

That’s all there is to it. Don’t forget to edit your “Notes Privacy” settings to ensure that people can see and comment on your imported feed items.

Once you successfully import your feed(s), they will appear by clicking on the “Notes” button in the left sidebar of your Home page. Also, your timeline or “Wall” will also display the most recent post from each of your feeds as they are published and pulled into Facebook. This makes it easy for your “Friends” to see what you have been up to elsewhere on the Web.

help me in plain english

Mon, 31 Aug 2009

This has got to be the most ironic comment I have ever read:

“hi i dun a stupid noooby mistake and dint think about encrytion i just put a pass in the change pass box and now when i attempt to see my main.php or index.php its sayin password no and error how can i reset back to having no password or were can i edit the bit so that a pass is automattically seen or if not posable how can i make it so i can put in the pass i made at some point so i can login this way? the 3rd is most prefered as this will help me with other projects i am planning as i am a php noob :s plz sum1 hu is clever help me in plain english”

Thanks, “jay” — you made my week with that one.

Read more on Tumblr..

Subscribe to Comments Recent Dialogue

  • kn33ch41: "But for good browsers such as Opera and Safari, most users are quite savvy, understanding the game and always keeping their browsers...
  • Paul: First off great list. Probably the one of the best I've ever seen. I enjoyed your limiting of The Wall, and Dark Side of the Moon. He...
  • kn33ch41: I use method three, and use method four when a selector only requires one property....
  • r-a-y: Great code. Just wondering if, in certain scenarios, a permalink can be longer than 255 characters. I can think of a weird exam...
  • Jeff Starr: Thanks Oliver! Glad you enjoy the book. Thanks for the great feedback :)...
  • Perry: I've read a number of these Image Preloading techniques today and would like to know the best approach to use. I use PHP 5.3 on th...
  • Infographiste PAO: I didn't know that Jeff, that's a kind of great news, usually ppl don't know about no or dofollow so now it's gonna be alright withou...
  • Bill Brown: @Jakub: Of course, there are many ways to bypass the XML declaration issue when you have PHP short tags enabled. Since the intenti...
  • bucabay: AT Jakub ...
  • Jakub Lédl: Oh sh*t, I came back. What happened to that code I posted? Does this CMS remove PHP from comments or what? I now look like an idiot :...

Read more recent comments..

Attention: Do NOT follow this link!