$img = array('jpg','jpeg','gif'...... ecc);

if ( in_array($path_parts['extension'], $img) )
{
echo "E' un'immagine!";
}