简体   繁体   中英

How do I set og:image so it takes image from page?

I am using mediawiki 1.19 and I've added facebook 'like'. When I click like the image posted is the site logo. How do I take the image from the page. I've run the site through http://developers.facebook.com/tools/debug and it seems og:image is set to the site logo. How do I change this meta property? My site is thepetwiki.com Thanks

You are going to gave to add some custom og:tags to the HTML markup of your page and specify the image that you want to use...

Take a look at the example from the Facebook documentation -

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:og="http://ogp.me/ns#"
      xmlns:fb="https://www.facebook.com/2008/fbml">
  <head>
    <title>The Rock (1996)</title>
    <meta property="og:title" content="The Rock"/>
    <meta property="og:type" content="movie"/>
    <meta property="og:url" content="http://www.imdb.com/title/tt0117500/"/>
    <meta property="og:image" content="http://ia.media-imdb.com/rock.jpg"/>
    <meta property="og:site_name" content="IMDb"/>
    <meta property="fb:admins" content="USER_ID"/>
    <meta property="og:description"
          content="A group of U.S. Marines, under command of
                   a renegade general, take over Alcatraz and
                   threaten San Francisco Bay with biological
                   weapons."/>
    ...
  </head>
  ...
</html>

As you can see the og:image parameter is specified here and that allows Facebook to correctly display the meta data associated with that URL...

You might not need all of the og:tags specified here, title , url , image and description should be fine for just a LIKE button.

You are already aware of the debugger tool - it will help you debug your LIKE button and og:tags . Make some changes in your HTML markup and each time you'll have to send your URL though the debugger to refresh Facebook's cached version of your URL.


A quick Google search gave me this mediawiki extension that looks like it could help you -

http://www.mediawiki.org/wiki/Extension:OpenGraphMeta

OpenGraphMeta provides OpenGraph protocol metadata for articles on the wiki for 3rd parties like Facebook to extract...

see post http://www.mediawiki.org/wiki/Extension_talk:Facebook#OpenGraph_image_problems . The open graph coding is all part of the Facebook extension.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM