$headers = get_headers('https://media.giphy.com/media/BvvBz8BnRqZOg/giphy.gif', 1); if (strpos($headers['Content-Type'], 'image/') !== false) { echo "Work"; } else { echo "Not Image"; }