本文介绍了将 Base64 jpeg 图像传递给 og:image的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的网站上有运行时生成的图像,我使用
I have image that is being generated in runtime on my website and I display it in html using
现在,我想让 Facebook 获取此图像,但是如果我对 og:image 元标记执行相同操作,则 Facebook 调试器会给我一个错误.有什么解决办法吗?
Now, I want for Facebook to fetch this image, but if I do the same for og:image meta tag, facebook debugger gives me an error. Any solution?
<meta property='og:image' content='data:image/jpeg;base64,<!-- base64 data -->'/>
当然,我想避免永久保存文件,因为它们总是不同的,而且很快就会变得太拥挤
Of course, I would like to avoid permanent saving of files since they are always different and it would get too crowded very quickly
推荐答案
将其粘贴到一个 php 文件中,然后将其回显:
pase it to a php file that echo it out:
<meta property='og:image' content='decoder.php?data=<!-- base64 data -->'/>
解码器.php:
<?php
echo base64_decode($_GET['data']);
?>
编辑出于安全原因,请确保检查来源.
EDITmake sure you check source for security reason.
这篇关于将 Base64 jpeg 图像传递给 og:image的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!