Facebook Share Button doesn't share the correct image

Hi there!

I saw a lot this kind of question about facebook and twitter share buttons.

I couldn’t find the right topic that helped me to continue with this discussion, but I think it was @PixelGeek that post some great tutorial about it that I followed and worked fine.

Basically I putted this code in the “custom code” section:

<div id="fb-root"></div>
<script>(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/es_ES/sdk.js#xfbml=1&version=v2.8";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>

<script language="javascript">
    function fbshareCurrentPage()
    {window.open("https://www.facebook.com/sharer/sharer.php?u="+escape(window.location.href)+"&t="+document.title, '', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=300,width=600');return false; }

Then in the designer I created a class called “fb-share-button” to style my share button. And then added an embed with the same class and this code on it:

<div class="fb-share-button" data-href="" data-layout="button_count" data-size="small" data-mobile-iframe="true"><a class="fb-xfbml-parse-ignore" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fdevelopers.facebook.com%2Fdocs%2Fplugins%2F&amp;src=sdkpreparse">Compartir</a></div>

That worked just fine until I started to put a custom image for every page.

I read someone had the same problem in this post but couldn’t find the answer. Can you please help me?

The only page that works fine is this one.

The others just share the page with the old image, witch is still in some pages. For example this other one.

Here is my share link and the link of the live website.

Sorry for the long question, hopefully it will be helpfull for others too.

Mr Potato Head says hi!

Clear the cache using this tool: https://developers.facebook.com/tools/debug

I’ve done this page for you: https://developers.facebook.com/tools/debug/sharing/?q=http%3A%2F%2Fwww.museodelbarro.org%2Fmuestras%2Fpyapy

1 Like

Wow, that’s it! It even solved the problem in the other pages somehow. Thank you very much!

And for anybody that’s looking for a dynamic share button, this is the solution and is very simple.

I know this is an old topic but does that mean it could me with this?