Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom image for Facebook share button

I've been searching around the internet for a while now and am unable to find anything that works. I want to use my own custom image for the share button but whenever I try to surround the image the share button disappears. Sorry for lack of information because I'm new to the Facebook SDK. Any help would be greatly appreciated, thanks.

Current code that I have:

<div class="fb-share-button" data-href="https://developers.facebook.com/docs/plugins/" data-layout="button"><img src="Images/Icons/facebook.png" class="link"></div>
like image 792
Joe Scotto Avatar asked Feb 13 '15 23:02

Joe Scotto


People also ask

How do I change the share button photo on Facebook?

right click on the button that you want to change "Inspect element" and find out if it really is an image or a CSS if it's an image find where the image is and upload your file with the same name ontop of the old one or if it's a CSS look for a button generator in google and just paste the code from there.

Is it possible to add custom parameters to the Facebook share button?

Facebook used to allow custom parameters in the Facebook share button, but it is not working now. What I need is to create a Facebook share button which will have a custom title, url, image, description, etc. It cannot be done using meta tags because there are multiple share buttons on a single page.

How to add images in Link shares on Facebook?

Images in Link Shares 1 The Open Graph meta-tag. The og:image tag can be used to specify the URL of the image that appears when someone shares the content to Facebook. 2 Requirements. The minimum allowed image dimension is 200 x 200 pixels. ... 3 Pre-caching images. ... 4 Updating images. ... 5 Troubleshooting. ...

How to create a share button on Facebook or Twitter?

Pick the URL of a website or Facebook Page you want to share. 2. Code Configurator. Paste the URL to the Code Configurator and adjust the layout of your share button. Click the Get Code button to generate your share button code. 3. Copy & Paste HTML snippet. Copy and past the snippet into the HTML of the destination website.

What does Facebook want us to do with the new Sharer?

It appears Facebook just wants us to share entire pages (based on url only). There's also their new share dialog, but even though they claim it can do all of what the old sharer.php could do, that doesn't appear to be true. And here's Facebooks 'best practices' for sharing.


1 Answers

This code works fine for me:

<!-- facebook -->
<img src="[YOUR_FACEBOOK_PIC]" alt="Share on Facebook" onclick="window.open('https://www.facebook.com/sharer/sharer.php?u='+encodeURIComponent('[YOUR_PAGE_URL]'),'facebook-share-dialog','width=626,height=436'); return false;">

<!-- twitter -->
<img src="[YOUR_TWITTER_PIC]" alt="Share on Twitter" onclick="javascript:window.open('https://twitter.com/share?text=[SOME_TEXT_TO_PREPOLUTATE_TWEET]&amp;url=[YOUR_PAGE_URL]','Twitter-dialog','width=626,height=436'); return false;">

<!-- google+ -->
<img src="[YOUR_GOOGLE_PIC]" alt="Share on Google Plus" onclick="window.open('https://plus.google.com/share?url=[YOUR_PAGE_URL]','Google-dialog','width=626,height=436'); return false;">

Just replace the text between brackets, and don't forget to "url encode" all the text that goes in the url to avoid issues.

And it doesn't need the SDK for any of them.


Here are references to the official documentation for each of them:

  • Facebook (you can see it under the URL redirection section)
  • Twitter (you could also use https://twitter.com/intent/tweet as described here)
  • Google+ (under Share Link section)
like image 75
Alvaro Montoro Avatar answered Oct 11 '22 21:10

Alvaro Montoro