ruby-on-railsfacebooksdkweb-deploymentshare-button

Customize the default Facebook Share button provided in developers.facebook.com


i have a custom image for facebook, that when the user click, it will share something, however, developers.facebook provide element that will automatically generate share button with the below code

<div class="fb-share-button" data-href="https://developers.facebook.com/docs/plugins/" data-layout="button"></div>

I want to use my custom image to use the code generated to popup the share page, is there a way?

%a.link.facebook{href: "some_url_here"}

I already search the net, still I'm stuck,

Thanks for your help , im still a beginner, :)


Solution

  • Many suggestion are useful, thanks to all of them, but i find this method more simple, I want to share it to you guys.

    Javascript (put it in header or footer)--

    <script>
    function fbShare(url, title, descr, image, winWidth, winHeight) {
        var winTop = (screen.height / 2) - (winHeight / 2);
        var winLeft = (screen.width / 2) - (winWidth / 2);
        window.open('http://www.facebook.com/sharer.php?s=100&p[title]=' + title + '&p[summary]=' + descr + '&p[url]=' + url + '&p[images][0]=' + image, 'sharer', 'top=' + winTop + ',left=' + winLeft + ',toolbar=0,status=0,width=' + winWidth + ',height=' + winHeight);
    }
    </script>
    

    to your link or image

    <a href="javascript:fbShare('http://jsfiddle.net/stichoza/EYxTJ/', 'Fb Share', 'Facebook share popup', 'http://goo.gl/dS52U', 520, 350)">Share</a>
    

    http://jsfiddle.net/stichoza/eyxtj/