TomasJ
TomasJ

Reputation: 279

Facebook like - php code - set og:image

I have facebook button on my site. It looks like:

<span class="fblike" style="float:right;padding-top:5px;margin-left:8px;">
    <div id="fb-root"></div>
        <script>
            window.fbAsyncInit = function() 
            {
                FB.init({appId: 'Your ID#', status: true, cookie: true,xfbml: true});
            };
            (function() {
                var e = document.createElement('script'); e.async = true;
                e.src = document.location.protocol + '//connect.facebook.net/sk_SK/all.js';
                document.getElementById('fb-root').appendChild(e);
            }());
        </script>
        <fb:like layout="button_count" show_faces="false" width="64" action="like" font="arial" colorscheme="light" />
</span>

My problem is, that I can't set og:image which I want :( whereever I place tag . It should be in tag but there is no in my default.php file. I'm working in joomla and it's one of my components.

Upvotes: 2

Views: 4986

Answers (2)

Wasim
Wasim

Reputation: 896

To display image of your choice on FB wall after all the intializations you should:

  1. Replace your HTML tag with

    <html xmlns="http://www.w3.org/1999/xhtml" xmlns:og="http://ogp.me/ns#" xmlns:fb="https://www.facebook.com/2008/fbml">
    
  2. Add og tags in your head section:

    <meta property="og:title" content="title of your page"/>
    <meta property="og:type" content="website"/>
    <meta property="og:url" content="url of your page"/>
    <meta property="og:image" content="path of image u want to display"/>
    <meta property="og:site_name" content="name of your site"/>
    <meta property="og:description" content="some brief description about your page "/>
    <meta property="fb:app_id" content="your fb app id"/>
    

After this you can check the data scrapped from your site using this debugger tool.

If there are no errors or warnings you are all set to use your like button.

Upvotes: 1

ahmetunal
ahmetunal

Reputation: 3960

Open Graph meta tags should be in the head section and your HTML should be correct. First, be sure of that.

Use this tool to check how facebook parses your website.

Upvotes: 0

Related Questions