mirror of
https://github.com/Intervention/image.git
synced 2025-08-13 09:24:05 +02:00
throw expection on 404 responses when trying to init from url
This commit is contained in:
@@ -53,6 +53,23 @@ abstract class AbstractDecoder
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Init from fiven URL
|
||||
*
|
||||
* @param string $url
|
||||
* @return \Intervention\Image\Image
|
||||
*/
|
||||
public function initFromUrl($url)
|
||||
{
|
||||
if ($data = @file_get_contents($url)) {
|
||||
return $this->initFromBinary($data);
|
||||
}
|
||||
|
||||
throw new \Intervention\Image\Exception\NotReadableException(
|
||||
"Unable to init from given url (".$url.")."
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if current source data is GD resource
|
||||
*
|
||||
@@ -225,7 +242,7 @@ abstract class AbstractDecoder
|
||||
return $this->initFromBinary($this->data);
|
||||
|
||||
case $this->isUrl():
|
||||
return $this->initFromBinary(file_get_contents($this->data));
|
||||
return $this->initFromUrl($this->data);
|
||||
|
||||
case $this->isFilePath():
|
||||
return $this->initFromPath($this->data);
|
||||
|
Reference in New Issue
Block a user