Pass Base64 jpeg image to og: image

I have an image that is created at runtime on my website and I display it in html using

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

Now I want Facebook to get this image, but if I do the same for the og: image meta tag, the facebook debugger will give me an error. Any solution?

 <meta property='og:image' content='data:image/jpeg;base64,<!-- base64 data -->'/> 

Of course, I would like to avoid the constant saving of files, since they are always different, and it would quickly overflow.

+4
source share
2 answers

drag it to a php file that repeats it:

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

decoder.php:

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

EDIT make sure that you check the source for security reasons.

+6
source

Open Graph needs a url.

You can try to save base64 as a temporary image.

+2
source

Source: https://habr.com/ru/post/1499091/


All Articles