I am trying to convert an jpg image on my Wordpress blog to base64. I use this php code but 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 image is being retrieved, just can't get it working. Anyone know what might be going on.