当我们分享这样的链接时,我们如何在我们的网站中包括一张图片来显示在WhatsApp上?
当前回答
额外的有用信息:
你可以提供几个og:图片,whatsapp将使用最后一个。这将有助于解决例如facebook想要1.91:1的比例和whatsapp 1:1的问题
<meta property="og:image" content="https://www.link.com/facebook.png" />
<meta property="og:image:type" content="image/png" />
<meta property="og:image:width" content="1200" />
<meta property="og:image:height" content="630" />
<meta property="og:image" content="https://www.link.com/whatsapp.png" />
<meta property="og:image:type" content="image/png" />
<meta property="og:image:width" content="400" />
<meta property="og:image:height" content="400" />
https://roei.stream/2018/11/18/ideal-open-graph-image-size-for-whatsapp-link-share/
https://css-tricks.com/essential-meta-tags-social-media/
其他回答
我尝试了这个线程下的几个建议,从我的外部搜索,但这对我来说是一个完全不同的问题。我使用og:image标记所指示的图像的特定指令正在被Jetpack插件提供的open graph标记所覆盖。你可以在这里找到我的详细答案。然而,我认为有必要在这个更多人关注的帖子中简要地添加这些步骤。希望这能帮助到一些人。
Facebook共享调试器帮助我确定了根本原因,从那里,我遵循以下步骤:
Debug your website using the debugger above. Simply type in the URL and hit debug. This should give you a list of warnings and once you scroll down to the open graph tags sections, you will be able to see the values that are being fetched for your website. The one to focus on is the og:image tag. Scroll further down to the "See exactly what our scraper sees for your URL" link and search for the og:image tag to find the villain in your story. Now simply, opt the means to remove an override that is occurring. In my case, I found the following function helpful. It changes the default image used any time Jetpack can not determine an image to use.
它改变默认图像使用任何时候,Jetpack不能确定一个图像使用
function custom_jetpack_default_image() {
return 'YOUR_IMAGE_URL';
}
add_filter( 'jetpack_open_graph_image_default', 'custom_jetpack_default_image' );
需要补充的是,建议图像参数最小为300px x 200px,大小< 300kb。如果这些一般的说明对你不起作用,请遵循这些说明,因为,那么你的问题很可能与我的问题相似。此外,有时最简单的解决方案可能只是删除插件(只要你验证你可以没有它)。
最后你应该能看到像这样的东西
希望这能有所帮助。
NS
如果你想在某人在WhatsApp上分享的你网站的url旁边放一张照片,你必须在url链接的页面上放一个元标签,就像这样:
<meta property="og:image" content="http://unrestrictedstock.com/wp-content/uploads/Unrestricted-Stock-Small.png"/>
在失去4个小时后,在这个话题上发表我的意见。
我正在编写一个用webpack编译的vue应用程序。 默认情况下,Webpack缩小了HTML,就像屠夫一样。它从许多属性中删除了双引号。
Whatsapp讨厌这一点! 它只是跳过属性值周围的引号格式不正确的字段。
关闭索引的最小化,一切都会好起来的!
下面是如何使用Vue-CLI,在vue.config.js文件中添加这个:
module.exports = {
chainWebpack: config => {
config.plugin('html')
.tap(args => {
args[0].minify = false
return args
})
}
来源:https://github.com/vuejs/vue-cli/issues/4328#issuecomment-595682922
以下行动对我的情况有所帮助。
将映像放在同一主机下。
<meta property="og:url" content="https://www.same-host.com/whatsapp-image.png" />
例如,通过前导子串检测用户代理,将所需图像传递给WhatsApp
WhatsApp/2.18.380 A
在真正按下发送按钮前等待几秒钟,以便WhatsApp有时间从og元数据中检索图像和描述。
2020标准
只需几个步骤,就能完美预览WhatsApp、Twitter、Facebook以及pc和移动设备上的书签图标。如果你喜欢阅读,去Open Graph (ogp.me) -但一定要阅读这个答案中的第1 - 6步,以获得最好的WhatsApp预览。
不同公司的许多技术审计结果表明,使用Open Graph标签不会帮助你获得更好的SEO排名,它们只适用于社交媒体。schema.org的数据结构将帮助您进行SEO。
这些Open Graph <meta>标签放在<head>标签里面。
请注意:@jaimish11提到一些应用程序或网站使用缓存,甚至将网站预览存储在他们的数据库中。这意味着当你在WhatsApp或Facebook上测试你的链接时,你很可能不会马上看到任何区别。使用另一个链接(另一个页面)可以达到目的。但是,只要您使用了该链接一次,这个“请注意”部分就会重新开始。
第一步:标题
不超过65个字符
<title>your keyword rich title of the website and/or webpage</title>
步骤2:描述
不超过155个字符
<meta name="description" content="description of your website/webpage, make sure you use keywords!" />
步骤3:og:title
最多35个字符
<meta property="og:title" content="short title of your website/webpage" />
步骤4:og:url
完整链接到当前网页地址
<meta property="og:url" content="https://www.example.com/webpage/" />
步骤5:og:description
最多65个字符
<meta property="og:description" content="description of your website/webpage" />
步骤6:og:image
图片(JPG或PNG),大小不超过300KB,最小尺寸为300x200 *。该映像应该通过HTTPS连接提供,该连接具有有效的非自签名证书
<meta property="og:image" content="//cdn.example.com/uploads/images/webpage_300x200.png" />
* @RichDeBourke mentioned this to me, but apparently WhatsApp has increased its maximum image size (dimensions as well as file size). I did some tests: it does not work consistently every time on every device. I tested 2.x Mb images and even that seemed to work 9/10 times. <300KB is the safest approach, but you should be fine using larger images as of 18-02-2020. I would recommend keeping the file size below 2MB, though. And definitely throw your image through TinyPNG or any other image compression algorithm if you haven't already.
** @Indraraj提到,如果您的网站运行在https上,并使用自签名证书,则图像可能不会显示。
如果你完成了上面的步骤,你现在可以在WhatsApp中看到你的预览!但是,请注意上面的“请注意”部分。
步骤7:og:type
为了在图中表示对象,您需要指定它的类型。以下是可用的全局类型列表:http://ogp.me/#types。您还可以指定自己的类型。
<meta property="og:type" content="article" />
步骤8:og:本地
资源的区域设置。如果有其他可用的语言翻译,也可以使用og:locale:alternate。
如果你不指定og:locale,它默认为en_US。
<meta property="og:locale" content="en_GB" />
<meta property="og:locale:alternate" content="fr_FR" />
<meta property="og:locale:alternate" content="es_ES" />
第九步:推特
要获得最好的Twitter支持,请阅读以下内容。
10 . Facebook
为了获得最好的Facebook支持,请阅读以下内容。
步骤11:favicon
要获得所有浏览器和设备的最佳favicon支持,请阅读本文。
额外步骤12:视频/音频
也可以共享音频/视频。例如,Facebook和Twitter就很好地分享视频。读ogp.me。当然,WhatsApp也有这样的选择:当你分享Instagram或Youtube链接时,WhatsApp的预览会与应用程序内的视频播放器一起提供。
超级奖励第13步:产品、人物、电影等。
这类信息实际上取决于提供商(Facebook,谷歌)。我不知道什么时候,但WhatsApp和Twitter可能会支持这些产品。通过这种方式,与你分享链接的人可能会在共享链接“小部件”中看到价格、平均评论分数。那太好了。对于在WhatsApp business应用程序中更新目录的企业帐户,这已经存在,但这与链接共享完全不同。
推荐文章
- 在notepad++中格式化代码
- 表单中包含表单,可以吗?
- 如何创建表只使用<div>标签和Css
- html5 - canvas元素-多层
- 如何确保<select>表单字段被禁用时提交?
- 如何在HTML文本换行?
- 如何在JavaScript中转义单引号(')?
- 如何使用HTML/CSS在文本中插入空格/制表符
- 用背景图像填充SVG路径元素
- 将JSON显示为HTML
- HTML被认为是一种编程语言吗?
- 如何修复favicon.ico错误:“Failed to load resource: net::ERR_EMPTY_RESPONSE”
- 这个CSS是如何产生一个圆的?
- 我如何显示点(“…”)在一个跨度与隐藏溢出?
- 画布在使用CSS时被拉伸,但正常使用“width”/“height”属性