简体   繁体   English

将Base64 jpeg图像传递给og:image

[英]Pass Base64 jpeg image to og:image

I have image that is being generated in runtime on my website and I display it in html using 我有在运行时在我的网站上生成的图像,我用html显示它

<img src="data:image/jpeg;base64,<!-- base64 data -->" />

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. 现在,我想让Facebook获取此图像,但如果我对og:image元标记执行相同操作,则facebook调试器会给我一个错误。 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 当然,我想避免永久保存文件,因为它们总是不同的,而且会很快变得过于拥挤

pase it to a php file that echo it out: 把它变成一个回复它的php文件:

<meta property='og:image' content='decoder.php?data=<!-- base64 data -->'/>

decoder.php: decoder.php:

<?php
    echo base64_decode($_GET['data']);
?>

EDIT make sure you check source for security reason. 编辑确保您出于安全原因检查源。

Open Graph needs an URL. Open Graph 需要一个URL。

You could try saving your base64 as a temp image. 您可以尝试将base64保存为临时图像。

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

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