I want to achieve something like this.
function buttonPressed() {
likePhotoWithUrl("mywebsite.com/myphoto.jpg");
}
So I can have a photo gallery with photos from my own website and add a button where people can like/share this image on facebook. Ideally this would have to be one constantly visible button that would dynammically like the url of the currently visible photo.
Is that possible?
Just use the regular Facebook Like Button - https://developers.facebook.com/docs/reference/plugins/like/ and write a script to change the data-href attribute of your Facebook Like Button HTML
<div class="fb-like" data-href="http://google.com" data-send="true" data-width="450" data-show-faces="true"></div>
Sample Script (with jQuery)
function buttonPressed() {
$('div.fb-like').attr('data-href', 'YOUR-NEW-URL');
}
And you need a page for your image, you can't just link it to the JPG file.