Published on: 30 Jul, 2013

Facebook Like, Share or Recommend button pick up the wrong image

Tumblr Digg Google Plus

You have a great article or product information on your site and you would like it to share with others in facebook. However, the facebook button picks up the wrong image or picture. This kind of situation is normal, especially when you have a lot images on your site. In order for the facebook to pick up the correct image, you can specify the meta image on your meta tags header. See below example: please replace the content value according to your image path.

 <meta property="og:image" content="">

Below is the sample code to do it dynamically in CSharp / C#.

//Import this namespace
using System.Web.UI.HtmlControls;

protected void Page_Load(object sender, EventArgs e){
    //we get the header object
    HtmlHead objHeader = (HtmlHead)Page.Header;

    //we add meta description
    HtmlMeta objMetaFacebook = new HtmlMeta();

    //Add the property id
    objMetaFacebook.Attributes.Add("id", "metafacebook");

    //Add the property og:image
    objMetaFacebook.Attributes.Add("property", "og:image");

    //specify the image path
    objMetaFacebook.Content = "";

    //This will add it to the header object

Once you have implemented the meta tags, you can do a debug testing by visiting facebook site and enter your site url address.


There are no comments available.

Write Comment
0 characters entered. Maximum characters allowed are 1000 characters.