So I have a server running windows on it, which is running a PHP environment to run a blog website.
Now the following code runs fine on my localhost using xampp, but does not work on the windows server.
$image = get_the_post_thumbnail_url($postId, array(150,150));
$ext = pathinfo($image, PATHINFO_EXTENSION);
$base64 = 'data:image/' . $ext . ';base64,' . base64_encode(file_get_contents($image));
The code gets the post thumbnail from the loop and creates a base64 image, which I use in a blur up image technique(Like what happens to the first two images on this site)
When I echo out the $ext
and $image
variables I get data, but when I echo the file_get_contents($image)
I get nothing. I can confirm the file does exist.
echo $ext . ':' . $image;
echo '<br />' . file_get_contents($image);
I came across the suggestion to allow_url_fopen
but when I check by echoing out phpinfo()
it is enabled
echo phpinfo();
The php version is 5.6 so that wouldn't be the problem either.
Also when I turn wordpress debug on for the windows server I get this error: Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: No such host is known.
Anyone know of other potential causes for this preblom. Cheers