Check if valid image

I have this:

PHP:

if (getimagesize($x->image_url) !== false) {

    echo "img";

}

The problem is that if the image url is badly formatted I am getting this:

Code (text):

Warning: getimagesize(http:///images/crap.jpg) [function.getimagesize]: failed to open stream: operation failed in bla…

Can you suggest a better code?
Thanks!

See original post by Fracisc

Leave a Reply