Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

<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. 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

like image 258
Vuk Stanković Avatar asked Aug 27 '13 08:08

Vuk Stanković


2 Answers

Paste it to a PHP file that echos it out:

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

decoder.php:

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

EDIT Make sure you check source for security reasons.

like image 160
exim Avatar answered Sep 19 '22 12:09

exim


Open Graph needs an URL.

You could try saving your base64 as a temp image.

like image 40
Gerben Jacobs Avatar answered Sep 18 '22 12:09

Gerben Jacobs