Don't use image alt tag if anchor title tag is empty

1,367 views
Skip to first unread message

Kat

unread,
Apr 26, 2010, 7:50:00 AM4/26/10
to fancybox
Hello,

I am using fancybox version 1.3.1 and want to use the anchor's title
tag to be used as the title of the image. If the title tag is empty I
don't want a title to appear at all.

But it seems that fancybox is set up to use the image's alt tag as a
title should the anchor title tag not exist or be empty.

Is there any way to switch this functionality off?


Many thanks,

Kat

--
You received this message because you are subscribed to the Google Groups "fancybox" group.
To post to this group, send email to fanc...@googlegroups.com.
To unsubscribe from this group, send email to fancybox+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/fancybox?hl=en.

JFK

unread,
Apr 26, 2010, 1:36:46 PM4/26/10
to fancybox
How title works in fancybox in a normal scenario:

for this script
$(".imagenes").fancybox();


1). for this html
<a class="imagenes" title="1a" alt="1b" href="images/01.jpg"><img
src="images/thumb01.jpg" title="2a" alt="2b"/></a>
- mouse over will show 2a as tooltip
- fancybox will show 1a as title

2). for this html
<a class="imagenes" alt="1b" href="images/01.jpg"><img src="images/
thumb01.jpg" title="2a" alt="2b"/></a>
- mouse over will show 2a as tooltip
- fancybox will show 2b as title

3). for this html
<a class="imagenes" alt="1b" href="images/01.jpg"><img src="images/
thumb01.jpg" title="2a" /></a>
- mouse over will show 2a as tooltip
- fancybox will show NO title at all

4). for this html
<a class="imagenes" title="1a" alt="1b" href="images/01.jpg">TEXT
LINK</a>
- mouse over will show 1a as tooltip
- fancybox will show 1a as title

5). for this html
<a class="imagenes" alt="1b" href="images/01.jpg">TEXT LINK</a>
- mouse over will show NOTHING
- fancybox will show 1b as title

NOW your case: If I understood right, you want a combination of
scenarios No. 1 and 2 but with the difference that scenario No. 2
shouldn't show any title in fancybox .... in other words, the alt
attribute in <img> tag shouldn't be used as title by fancybox, is that
correct?

I am not sure that there is a switch to disable this functionality but
you may want to use this script as a workaround:

function titleOnly(){return this.title;}
$(".imagenes").fancybox({
'title': titleOnly
});

Kat

unread,
Apr 29, 2010, 9:57:30 AM4/29/10
to fancybox
Wow, JFK, thank you so much for your extensive and incredibly useful
answer.

The function you have supplied works a treat!

Kat
Reply all
Reply to author
Forward
0 new messages