1
I would like to add a facebook share button to overlay Fancybox 2.1.5 on instagram photos.
At the moment I have a button like that works but that’s not what I want, what I really wanted was a button share, I tried everything and I couldn’t.
My code:
HTML
<script src="js/fancybox.js"></script>
<!-- ..... -->
<a class="group" rel="group1" href="https://scontent.cdninstagram.com/hphotos-xpa1/t51.2885-15/e15/10561180_1559579060958937_1557237818_n.jpg">
<img onclick="open_fancy();" src="https://scontent.cdninstagram.com/hphotos-xpa1/t51.2885-15/s150x150/e15/10561180_1559579060958937_1557237818_n.jpg">
</a>
<br>
<div class="textPhoto"><p>Qua, março 25 de 2015</p></div>
<div class="usernamePhoto">joycedoret</div>
<div class="fullNamePhoto">Joyce Doret</div>
<div class="displayVotesPhotos">1</div>
<div class="vote-button" data-numOfVotes="1" data-vote="https://scontent.cdninstagram.com/hphotos-xpa1/t51.2885-15/e15/10561180_1559579060958937_1557237818_n.jpg">Votar</div>
</div>
<div class="wrapper-image" style="position:relative;display:inline-block;">
<a class="group" rel="group1" href="https://scontent.cdninstagram.com/hphotos-xfa1/t51.2885-15/e15/11055938_789110064513812_1432468196_n.jpg">
<img onclick="open_fancy();" src="https://scontent.cdninstagram.com/hphotos-xfa1/t51.2885-15/s150x150/e15/11055938_789110064513812_1432468196_n.jpg">
</a>
<br>
<div class="textPhoto"><p>Qua, abril 01 de 2015</p></div>
<div class="usernamePhoto">rutemcaetano</div>
<div class="fullNamePhoto">Rute Caetano</div>
<div class="displayVotesPhotos">2</div>
<div class="vote-button" data-numOfVotes="2" data-vote="https://scontent.cdninstagram.com/hphotos-xfa1/t51.2885-15/e15/11055938_789110064513812_1432468196_n.jpg">Votar</div>
</div>
<!-- .... -->
JS
$(document).on('click', '.wrapper-image > a', function(){
return false;
});
function open_fancy() {
$(function() {
$("a.group").fancybox({
openEffect : 'elastic',
closeEffect : 'elastic',
beforeShow: function () {
this.title = '<br />';
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'
}
}
});
});
}
Here is an example in Jsfiddle button like.
Very well, thank you
– Miguel
There is a problem in your js, only the first image where fancybox.js is executed gets the share button, on Monday it is no longer possible. In my code not the first, without understanding why
– Miguel
@Miguel Thanks for the alert, in the course of tests I ended up annulling the
else { ... }
which should instantiate the button (which is done in callback of the script call). Solved and tested! :)– Zuul
Fire, now "invalid version specified" in relation to
fb.init
... All right Very obnoxious– Miguel
You may have to alter the path to the script. The latest version uses this:
//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.3
instead of what I used to assemble the test.– Zuul
I managed with a few changes to your. http://jsfiddle.net/4tqbbbjm/5/. I just specified the version and changed the link to the script. Very busy
– Miguel