gpt4 book ai didi

javascript - PHP : customize image in share link to facebook

转载 作者:行者123 更新时间:2023-12-03 02:52:12 24 4
gpt4 key购买 nike

我使用如下脚本来共享 Facebook 链接:

<a class="facebook" href="https://www.facebook.com/sharer/sharer.php?u=&t=" title="Share on Facebook" target="_parent" onclick="window.open('https://www.facebook.com/sharer/sharer.php?u=' + encodeURIComponent(document.URL) + '&t=' + encodeURIComponent(document.URL), 'sharer', 'toolbar=0,status=0,width=548,height=325'); return false;"></a>

只是弹出分享到facebook时,图片太大(按照原图)。如何设置图片最小化?例如,原始尺寸为 700x700 图像..当共享图像变为 200x200 时。解决办法是什么?

最佳答案

根据facebook best practices :

Image Sizes

Use images that are at least 1200 x 630 pixels for the best display on high resolution devices. At the minimum, you should use images that are 600 x 315 pixels to display link page posts with larger images. Images can be up to 8MB in size.

We've also redesigned link page posts so that the aspect ratio for images is the same across desktop and mobile News Feed. Try to keep your images as close to 1.91:1 aspect ratio as possible to display the full image in News Feed without any cropping.

您还应该检查 open graph protocol 、设置页面图片元数据示例:

<meta property="og:image" content="http://example.com/ogp.jpg" />
<meta property="og:image:secure_url" content="https://secure.example.com/ogp.jpg" />
<meta property="og:image:type" content="image/jpeg" />
<meta property="og:image:width" content="400" />
<meta property="og:image:height" content="300" />
<meta property="og:image:alt" content="A shiny red apple with a bite taken out" />

关于javascript - PHP : customize image in share link to facebook,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47804825/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com