diff --git a/src/Imagine/Loader/LoaderManager.php b/src/Imagine/Loader/LoaderManager.php index 7d90d5b..e19dd68 100644 --- a/src/Imagine/Loader/LoaderManager.php +++ b/src/Imagine/Loader/LoaderManager.php @@ -70,7 +70,10 @@ public function loadBinary($relativePath, $filter) $imageLoader = $this->defaultImageLoader; } if (!is_object($imageLoader)) { - $imageLoader = $this->imageLoaders->get($imageLoader); + $imageLoader = $this->imageLoaders->get( + $imageLoader, + isset($filterOptions['loader_options']) ? $filterOptions['loader_options'] : [] + ); } $binary = $imageLoader->load($relativePath); diff --git a/tests/HtImgModuleTest/Imagine/Loader/LoaderManagerTest.php b/tests/HtImgModuleTest/Imagine/Loader/LoaderManagerTest.php index fd3f13b..eeca375 100644 --- a/tests/HtImgModuleTest/Imagine/Loader/LoaderManagerTest.php +++ b/tests/HtImgModuleTest/Imagine/Loader/LoaderManagerTest.php @@ -25,7 +25,18 @@ public function testGetExceptionWhenImageLoaderCannotLoadImage() $loadManager->loadBinary($relativePath, 'asdf'); } - public function testLoadBinary() + public function getData() + { + return [ + ['awesome_image_loader', ['loader_options' => ['a' => []]]], + ['awesome_image_loader_2', []], + ]; + } + + /** + * @dataProvider getData + */ + public function testLoadBinary($imageLoaderName, $filterOptions) { $imageLoaders = $this->getMock('Zend\ServiceManager\ServiceLocatorInterface'); $filterManager = $this->getMock('HtImgModule\Imagine\Filter\FilterManagerInterface'); @@ -37,14 +48,14 @@ public function testLoadBinary() $relativePath = 'relative/path/of/some/image'; $filter = 'bar_filter'; - $imageLoaderName = 'some_image_loader'; $binaryContent = 'asdf55asd4f53as4df54asdf564asdf'; $mimeType = 'image/png'; + $filterOptions['image_loader'] = $imageLoaderName; $filterManager->expects($this->once()) ->method('getFilterOptions') ->with($filter) - ->will($this->returnValue(['image_loader' => $imageLoaderName])); + ->will($this->returnValue($filterOptions)); $imageLoaders->expects($this->once()) ->method('get')