I'm trying to convert an image on my wordpress blog to base64.
When I use this website to do it manually it works.
But when I try it in PHp it's not working:
$thePostThumb = get_the_post_thumbnail($postId, array(150,150));
background-image: url(\'data:image/jpg;base64,' . base64_encode($thePostThumb) . '\');
I have also tried this method:
$type = pathinfo(get_the_post_thumbnail_url($postId, array(150,150)), PATHINFO_EXTENSION);
$data = file_get_contents(get_the_post_thumbnail_url($postId, array(150,150));
$base64 = 'data:image/' . $type . ';base64,' . base64_encode($data)
I know the thumb img is being retrieved, just can't get it working. Anyone know what might be going on. I'm using xampp and developing on local machine