1
0
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:
Oliver Vogel
2014-12-11 15:49:08 +01:00
parent 0d2eb58585
commit f9bd6c102b

View File

@@ -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);