简体   繁体   English

为什么即使og指向正确大小的文件,Facebook共享图像也显得很小

[英]Why Facebook share image appears small even when og directs to right sized file

I'm making a Facebook sharer with FB UI. 我正在使用FB UI进行Facebook分享。 I have og tag: 我有og标签:

<meta property="og:image" content="https://www.mydomain.fi/img/fb-share-img.jpg" />

The image is 1200 × 627. The og debugger doesn't give any errors. 图像为1200×627。og调试器未给出任何错误。 However, when sharing the link, share image appears to be small square instead of full width image. 但是,共享链接时,共享图像似乎是小正方形而不是全角图像。

What might cause this? 是什么原因造成的?

The weird thing is that earlier og was fetching the data right and showed the photo bigger. 奇怪的是,早期的og正确地获取了数据并显示了更大的照片。 I had to debug something and fetch the site again and now I can't get the big image back. 我不得不调试某些东西,然后再次获取该站点,现在我无法恢复大形象了。

I, too, had all the right og: tags and a large share image. 我也有所有合适的og:标签和较大的共享图片。 When sharing the url directly, I got a large image. 直接共享网址时,我得到了一个很大的图像。 When sharing from the Facebook JS SDK, it started out as large, then suddenly got small. 从Facebook JS SDK进行共享时,它最初是很大的,然后突然变小了。 As others have pointed out, this is almost a random selection based on FB algorithms. 正如其他人指出的那样,这几乎是基于FB算法的随机选择。 Having spent many hours fighting with tags and the debug tool, I accidentally stumbled upon a hack (use at own risk): 在花了很多时间与标签和调试工具进行斗争之后,我偶然发现了一个黑客程序(使用风险自负):

Without knowing it, I copy-pasted an og:type tag from another website which contained an invalid character (in my case the quotation marks were "printer's quotes") 不知不觉中,我从另一个网站复制粘贴了og:type标签,该标签包含无效字符(在我的情况下,引号是“打印机的引号”)

meta property="og:type" content=”website” (see the difference between the quotes around "og:type" and "website"?) meta property =“ og:type” content =“网站” (查看“ og:type”和“网站”之间引号之间的区别?)

To my stunned disbelief, while this caused on error in the debug tool ("Object at URL '[myurl]' is invalid because the configured 'og:type' of '”website”/' is invalid.") it actually forced the large image to be used , and all other meta data was fine. 令我惊讶的是,尽管这是调试工具中的错误所导致的(“ URL'[myurl]'上的对象无效,因为配置的'“ website” /'的'og:type'无效。”)实际上迫使要使用的大图片 ,其他所有元数据都可以。

I have no idea how or why, so don't ask. 我不知道如何或为什么,所以不要问。 But it worked. 但这行得通。 All the time. 每时每刻。 And I hope this helps some other developers out there until we can be assured of the correct size image being shown. 我希望这对那里的其他开发人员有所帮助,直到我们可以确保显示正确的尺寸图像为止。 As I said, your mileage may vary, and don't blame me if you break it :) 就像我说的那样,您的里程可能会有所不同,如果您摔坏了,也不要怪我:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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