1
0
mirror of https://github.com/Intervention/image.git synced 2025-08-19 12:11:26 +02:00

Update AbstractDecoder.php

Several image providers have detection for which user agent is being used. 
Since I had several times issue's with that images where unavailable for Intervention since an missing user agent, I decided to add this header to get rid of the problems.
This commit is contained in:
mmjjb
2017-01-20 14:25:05 +01:00
committed by GitHub
parent 745d807d01
commit f87c7de1af

View File

@@ -61,7 +61,18 @@ abstract class AbstractDecoder
*/
public function initFromUrl($url)
{
if ($data = @file_get_contents($url)) {
$options = array(
'http' => array(
'method'=>"GET",
'header'=>"Accept-language: en\r\n".
"User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.2 (KHTML, like Gecko) Chrome/22.0.1216.0 Safari/537.2\r\n"
)
);
$context = stream_context_create($options);
if ($data = @file_get_contents($url, false, $context)) {
return $this->initFromBinary($data);
}