I'm using the following code to quickly verify whether a link is an image or not...
if (getimagesize($imageLink)) {
} else {
echo "notImage";
exit();
}
It works in practically all cases (i.e. if the browser returns an image, then getimagesize will return something), but I've found some cases where it doesn't work - e.g. for this link...
This applies generally to the reuters website and I'm sure a few others, but I'm really struggling to understand why there's this problem since the browser manages to return an image. I originally thought that getimagesize needed the path to the file explicitly stated (e.g. ending in .jpg, .png etc), but then again a link like this works fine...
Would really appreciate any thoughts from anyone having any ideas why getimagesize doesn't return an image in the first example but does in the second - and any suggestions on how to adapt the code to account for the reuters example would also be fantastic!!
use as it
<?php
list($width, $height) = getimagesize("http://s4.reutersmedia.net/resources/r/?m=02&d=20160330&t=2&i=1128905435&w=&fh=545px&fw=&ll=&pl=&sq=&r=LYNXNPEC2T0YW");
$arr = array('h' => $height, 'w' => $width );
print_r($arr); //output - Array ( [h] => 545 [w] => 968 )
?>