when I\'m trying to getimagesize($img) and the image doesn\'t exist, I get an error. I don\'t want to first check whether the file exists, just handle the error.
getimagesize($img)
This solution has worked for me.
try { if (url_exists ($photoUrl) && is_array (getimagesize ($photoUrl))) { return $photoUrl; } } catch (\Exception $e) { return ''; }