Search code examples
phpthumb

No connection could be made error in phpThumb()


I'm using phpThunmb to display images from external link. for some images, such type of error occurred as below.

enter image description here

i tried to get the header information of that image as below..

 $headers = get_headers($external_image_url);

but the result was empty. how to solve this error? if this image can not be accessed then how to display an alternate "image imageNotFound.jpg" in it's place .


Solution

  • try this code to check if the given image exists or not.

    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
        }