Skip to content

Commit

Permalink
Throwing an error if source image doesn't exist
Browse files Browse the repository at this point in the history
  • Loading branch information
fixe authored and Tiago Ribeiro committed Apr 14, 2012
1 parent 0ee7a14 commit e629756
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Imagine/Data/Loader/FileSystemLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ public function __construct(ImagineInterface $imagine, $formats, $rootPath)
*/
protected function getFileInfo($absolutePath)
{
if (!file_exists($absolutePath)) {
throw new NotFoundHttpException(sprintf("Source image '%s' doesn't exist", $absolutePath));
}

return pathinfo($absolutePath);
}

Expand All @@ -61,7 +65,8 @@ public function find($path)
throw new NotFoundHttpException(sprintf("Source image was searched with '%s' out side of the defined root path", $path));
}

$info = $this->getFileInfo($this->rootPath.'/'.ltrim($path, '/'));
$file = $this->rootPath.'/'.ltrim($path, '/');
$info = $this->getFileInfo($file);
$absolutePath = $info['dirname'].'/'.$info['basename'];

$name = $info['dirname'].'/'.$info['filename'];
Expand Down

4 comments on commit e629756

@web-dev
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit has intercepted the behaviour I introduced where Imagine would search for files without file extensions if there was no file extension with one.

What error was this introduced to correct?

@lsmith77
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are correct .. this exception needs to be removed. sorry for taking so long to react

@web-dev
Copy link

@web-dev web-dev commented on e629756 May 5, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problems, I've actually migrated to storing the source images in GridFS and have created a GridFS loader for this purpose. It actually works really well.

@lsmith77
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool. i have fixed the issue now. feel free to contribute your loader.

Please sign in to comment.