Skip to content

Commit

Permalink
Merge pull request #100 from johnnyborg/master
Browse files Browse the repository at this point in the history
catch the \InvalidArgumentException and use config to continue.
  • Loading branch information
Gregwar committed Oct 21, 2016
2 parents ab73f5d + cf2bc22 commit 9d643be
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions Services/ImageHandling.php
Expand Up @@ -91,8 +91,19 @@ public function __construct($cacheDirectory, $cacheDirMode, $handlerClass, Conta
public function open($file)
{
if (strlen($file) >= 1 && $file[0] == '@') {
$file = $this->fileLocator instanceof FileLocatorInterface
? $this->fileLocator->locate($file) : $this->fileLocator->locateResource($file);
try {
if ($this->fileLocator instanceof FileLocatorInterface) {
$file = $this->fileLocator->locate($file);
} else {
$this->fileLocator->locateResource($file);
}
} catch (\InvalidArgumentException $exception) {
if ($this->throwException || false == $this->fallbackImage) {
throw $exception;
}

$file = $this->fallbackImage;
}
}

return $this->createInstance($file);
Expand Down

0 comments on commit 9d643be

Please sign in to comment.