$webpsupport = (strpos($_SERVER['HTTP_ACCEPT'], 'image/webp') >= 0); if($webpsupport) { $this->attemptToServeWebP($pathinfo, $matches, $width, $height, $density); } else { $this->attemptToServeNormal($pathinfo, $matches, $width, $height, $density); }