我使用phpThunmb显示来自外部链接的图像。对于某些图像,此类错误发生如下。
我试图获取该图像的标题信息如下..
$headers = get_headers($external_image_url);
但结果是空的。如何解决这个错误?如果无法访问此图像,那么如何显示备用"图像imageNotFound.jpg"在它的位置。
答案 0 :(得分:1)
尝试此代码以检查给定图像是否存在。
if(file_exists($external_image_url))
{
$image_link = $external_image_url; //if that image exists
}
else
{
$image_link = "imageNotFount.jpg"; //if that image does not exists
}