【问题标题】:Share custom image with Google+与 Google+ 分享自定义图片
【发布时间】:2013-07-11 07:23:53
【问题描述】:

我在我的网站页面上使用 Twitter、google+ 和 Facebook 共享,其中 Facebook 和 Twitter 工作正常,但在 Google+ 中,它正在使用带有共享链接的默认图像。我希望它是我自己的图像,就像我在Facebook。我试过了:

  1. -来自http://www.addthis.com/
  2.     <!-- Place this tag after the last share tag. -->
        <script type="text/javascript">
          (function() {
            var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
            po.src = 'https://apis.google.com/js/plusone.js';
            var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
          })();
        </script>
    

    -来自https://developers.google.com/+/web/share/

  3. 为图像设置架构的所有方法 -来自https://developers.google.com/+/web/snippet/ 但它们似乎都不能正常工作。还有其他方法可以完成吗?

【问题讨论】:

    标签: php google-api google-plus


    【解决方案1】:

    填充 +Snippet 的方法

    使用 Schema.org 微数据(推荐方式):

    <body itemscope itemtype="http://schema.org/Product">
      <h1 itemprop="name">Shiny Trinket</h1>
      <img itemprop="image" src="{image-url}" />
      <p itemprop="description">Shiny trinkets are shiny.</p>
    </body>
    

    使用 Open Graph 属性:

    <meta property="og:title" content="..." />
    <meta property="og:image" content="..." />
    <meta property="og:description" content="..." />
    

    标题和元“描述”标签:

    如果页面的&lt;head&gt; 元素包含&lt;title&gt;&lt;meta name="description" ... /&gt; 标记,则+Snippet 将描述元标记的标题和内容属性用于sn-p 描述。对于缩略图,共享框会尝试在页面上找到合适的图像。

    <title>...</title>
    <meta name="description" content="..." />
    

    根据页面内容的最佳猜测(不推荐): 如果之前的数据都不存在,Google 会解析页面并尝试找到最佳标题、描述和图片。

    提取自documentation

    希望这会有所帮助!

    【讨论】:

      【解决方案2】:

      如果您想将用户带到另一个选项卡,请使用以下代码。

      <a href="https://plus.google.com/share?url=<?php the_permalink(); ?>" >Share on Google+</a>
      

      如果你想要一个弹出窗口,请使用下面的代码。

      <a href="#" onclick="popUp=window.open('https://plus.google.com/share?url=<?php the_permalink(); ?>', 'popupwindow', 'scrollbars=yes,width=800,height=400');popUp.focus();return false">Share on Gogole+</a>
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-10-19
        • 2023-03-17
        • 1970-01-01
        • 2012-12-08
        • 2012-09-22
        相关资源
        最近更新 更多