The goal :
I would like to have a share button in my fancybox that share the image I'm looking at with the correct image name in the Facebook sharer. I would like that when a user click on this in Facebook, he arrives on an opened Fancybox with the correct image.
The problem :
I have a gallery with Jquery FancyBox (http://fancyapps.com/fancybox/). I added a share button with the code I find in this fiddle (http://jsfiddle.net/G5TC3/).
My share button works, but get the meta og from the site and I want to have the og:image from the image I'm looking at.
$(".fancybox")
.attr('rel', 'gallery')
.fancybox({
beforeShow: function () {
if (this.title) {
// Add FaceBook like button
this.title += '<iframe src="//www.facebook.com/plugins/like.php?href=' + this.href + '&layout=button_count&show_faces=true&width=500&action=like&font&colorscheme=light&height=23" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:110px; height:23px;" allowTransparency="true"></iframe>';
}
},
helpers : {
title : {
type: 'inside'
}
}
});
For the user who clicks on my link and arrives on an opened Facybox with the correct image I have no idea how to do that and if it's possible.
What I know:
I know that I have to have uniques URL for each images and I think I have it. ex from my site:
www.myURL.com/images/gallery/myimages_1.jpg
www.myURL.com/images/gallery/myimages_2.jpg
Is it correct?
I think I have to change the "this.href" in the sharer by the image url. First is it correct? And second (sorry I'm new in javascript) how can I do that?
I hope somebody could help me. Sorry for my English I'm trying to write my best English :) If you need more information please do not hesitate.
Thanks
[EDIT]:
I add this script on the gallery page
$(function()
{
$('.thumbs').click(function()
{
$tempImgName = $(this).attr('id');
$tempUrl = this.href + '/images/thumbs/' + $tempImgName;
$meta = document.getElementById('facebook');
$meta.setAttribute("content",$tempUrl);
});
});
So when I click on a thumbsnail (with the class .thumbs) I get the image URL and I change the meta (with the facebook Id). It works but I think Facebook check the meta when the page load so how can I force Facebook to recheck my meta to take the good thumbs to share?