Eliminate Duplicate Images from Fancybox

2,954 views
Skip to first unread message

RichardH

unread,
Oct 2, 2012, 9:19:59 AM10/2/12
to fanc...@googlegroups.com
I posted this as a replay to another thread, but it didn't get an answer there, so I'm trying again. 

I have fancybox 2.1 integrated into my pages, and it works well, but as I am using image maps with sliced images, I get duplicate instances of the linked images when the slideshow or next/prev navigation is shown. The problem is that the same image is linked to from more than one hotspot in the underlying images.

 What I'd like to do is to eliminate the extra occurrences from the list of images after the image list is loaded, probably using a callback. I'd leave only the first instance of each image. This is a bit beyond my jquery competence, has anybody done this before and can point me in the right direction?

Thanks!

JFK

unread,
Oct 2, 2012, 3:00:25 PM10/2/12
to fanc...@googlegroups.com
don't know what is creating the duplicates, maybe another plugin that clones those images
the first approach is to remove the rel attribute (or the data-fancybox-group) attribute from the duplicated images in the html code

RichardH

unread,
Oct 2, 2012, 3:35:46 PM10/2/12
to fanc...@googlegroups.com
The duplicates are because the page as a whole contains multiple references to the same expanded image. If the page was not composed of image slices to speed loading (and reduce size), then there would be only only hotspot that links to each image. As there are slices, some of the hotspots are sliced and split across several images, giving multiple links. Each hotspot needs to have the data-fancybox-group attribute in order for the link to activate fancybox.

Richard

JFK

unread,
Oct 2, 2012, 9:08:04 PM10/2/12
to fanc...@googlegroups.com
data-fancybox-group doesn't necessarily activate fancybox ... it is used to group elements within a gallery ... a class or ID selector can be used to launch fancybox. In your case you could the data-fancybox-group attribute from the duplicated elements.

JFK

unread,
Oct 2, 2012, 9:08:46 PM10/2/12
to fanc...@googlegroups.com
I meant : In your case you could REMOVE the data-fancybox-group attribute from the duplicated elements

RichardH

unread,
Oct 3, 2012, 6:58:14 AM10/3/12
to fanc...@googlegroups.com
Ah, that does work, sorry for not reading your original reply closely enough. I added a class to the duplicate images and then removed the data-fancybox-group attribute from all those occurences. I'll try writing something a bit more sophisticated later.

Thanks Richard

Neo

unread,
Oct 10, 2012, 7:55:21 AM10/10/12
to fanc...@googlegroups.com
Please, can i get more details on how to do what u did for a coding rookie :)

i'm having the same problem of duplicate images and i'd really love to know how to fix it.
where is this data-fanxybox-group?? and how to delete it.

i'm using WP theme.

thanks

JFK

unread,
Oct 10, 2012, 11:37:51 PM10/10/12
to fanc...@googlegroups.com
look at the html code for something like
<a href="images/myimage.jpg" data-fanxybox-group="group" class="fancybox"><imgr src="images/thumbnail.jpg" alt="" /></a>

then remove the data-fanxybox-group when the value of the href attribute is duplicated
Message has been deleted
Message has been deleted
Message has been deleted

englebert

unread,
Nov 15, 2012, 12:43:47 PM11/15/12
to fanc...@googlegroups.com
having one of those quietly going mad days
none of the above works
delete all my entries - I give up for now

RavanH

unread,
Nov 16, 2012, 4:32:50 PM11/16/12
to fanc...@googlegroups.com

having one of those quietly going mad days
none of the above works
delete all my entries - I give up for now

We all have them, madly brilliant ideas that just don't work...  And then it's one of *those* days too... ;)

So no problem and thanks for trying. And if you can fix your code tomorrow -- not one of those days, trust me -- please, came back and share! :)
Reply all
Reply to author
Forward
0 new messages