/** * Test if the file is an image * @param string $url the url to the file * @return bool true if image */ protected function isImage($url) { // check for empty urls if (!$url) { return false; } $file = $this->getFile($url); $sniffer = new \SimplePie_Content_Type_Sniffer($file); return $sniffer->image() !== false; }
/** * Test if the file is an image * @param string $url the url to the file * @return bool true if image */ protected function isImage($url) { // check for empty urls if (!$url) { return false; } $file = $this->getFile($url); $status_range = (string) substr($file->status_code, 0, 1); //echo $status_range; if ($status_range == 2 || $status_range == 3 || !empty($status_range)) { // 200's are a good response and 300's are redirects $sniffer = new \SimplePie_Content_Type_Sniffer($file); return $sniffer->image() !== false; } }