0

I want to use a Facebook like/share button on my Images Website which uses a client side image JavaScript.The images are sourced externally(external image urls) and contained in array within script. To create a pageload with each image navigation, the image Script contains a CurrentURL function(dont exactly know what it is) and it changes website URL with each image navigation(suggesting that the images are hosted on my site). I have used custom share/like button (found it on stackoverflow and modified it) which shares the currectURL correctly on FB but fails to load the thumbnail image from pics array.

<script type="text/javascript"> 
var dynLike = document.createElement('fb:like');
dynLike.setAttribute('data-href', document.URL);
dynLike.setAttribute('picture', pics[a]); ( **i have added this for image thumbnail** )
dynLike.setAttribute('share', 'true');
dynLike.setAttribute('width', '450');
dynLike.setAttribute('show_faces', 'false');
document.body.appendChild(dynLike); // Or wherever you want it
FB.XFBML.parse();
</script>

The link to share/like in the above code document.URL (currentURl) comes from the image JavaScript I am using on my website. And pics[a] is image links in the array of image javascript.

Please help me with this, what changes can be done in this code to load the thumbnail image from pics array with current Url in the browser window.

Sam Mak
  • 23
  • 1
  • 10
  • The picture is going to be fetch by looking at the og:image tag at the specified url – WizKid Oct 26 '14 at 23:36
  • @WizKid the thumbnail is loading when document.URL is replaced with pics[a] in the above code, but its loading with the image Url itself, not with my website Url and clicking it would take the user to image only page. I am Currently using this [Share Button](http://stackoverflow.com/questions/21206283/how-to-add-facebook-like-and-comments-box-to-image-javascript/21437553?noredirect=1#comment40438808_21437553) script on my website and it works perfectly, sharing image and associated url to my site. I want acheive the same with like button and comment box. Please help – Sam Mak Oct 27 '14 at 19:11
  • The like button will like the url and we will scrape the url to file the og:image and use that. – WizKid Oct 29 '14 at 18:29
  • @WizKid thanks for replying. so what could be done to make it work? Currently i am using this [share button](http://stackoverflow.com/questions/24970732/custom-facebook-comment-box-for-currenturl) on my [site](http://www.woofhits.com/2013/08/funny-pictures.html) and it works great, can this be modified in some way to use with like button and comment box? – Sam Mak Oct 31 '14 at 13:50

0 Answers0