From 773ac252b067f7c93d6986d93c92fa33e06bb4c1 Mon Sep 17 00:00:00 2001 From: Martin Ficzel Date: Thu, 18 Oct 2018 17:05:01 +0200 Subject: [PATCH 1/2] BUGFIX: Add fallback to UriImageSourceHelper for SVG images The AssetImageSource will create an UriImageSourceHelper if an svg image was selected. --- .../AssetImageSourceImplementation.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Classes/FusionObjects/AssetImageSourceImplementation.php b/Classes/FusionObjects/AssetImageSourceImplementation.php index 55c27e9..74e20b3 100644 --- a/Classes/FusionObjects/AssetImageSourceImplementation.php +++ b/Classes/FusionObjects/AssetImageSourceImplementation.php @@ -2,12 +2,26 @@ namespace Sitegeist\Kaleidoscope\FusionObjects; use Neos\Flow\Annotations as Flow; +use Neos\Flow\ResourceManagement\ResourceManager; use Sitegeist\Kaleidoscope\EelHelpers\ImageSourceHelperInterface; use Sitegeist\Kaleidoscope\EelHelpers\AssetImageSourceHelper; use Neos\Fusion\FusionObjects\AbstractFusionObject; class AssetImageSourceImplementation extends AbstractImageSourceImplementation { + /** + * @Flow\Inject + * @var ResourceManager + */ + protected $resourceManager; + + /** + * @var array + */ + protected $nonScalableMediaTypes = [ + 'image/svg+xml' + ]; + /** * @return mixed */ @@ -36,6 +50,11 @@ public function createHelper() : ?ImageSourceHelperInterface return null; } + if (in_array($asset->getResource()->getMediaType(), $this->nonScalableMediaTypes)) { + $uri = $this->resourceManager->getPublicPersistentResourceUri($asset->getResource()); + return new UriImageSourceHelper($uri); + } + $helper = new AssetImageSourceHelper($asset); $helper->setAsync((bool)$this->getAsync()); $helper->setRequest($this->getRuntime()->getControllerContext()->getRequest()); From 68e14fca9f946add97c4d9a30ab5b287edc11999 Mon Sep 17 00:00:00 2001 From: Martin Ficzel Date: Thu, 18 Oct 2018 17:08:35 +0200 Subject: [PATCH 2/2] BUFIX: Cleanup use statements --- Classes/FusionObjects/AssetImageSourceImplementation.php | 2 +- Classes/FusionObjects/DummyImageSourceImplementation.php | 1 - Classes/FusionObjects/UriImageSourceImplementation.php | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/Classes/FusionObjects/AssetImageSourceImplementation.php b/Classes/FusionObjects/AssetImageSourceImplementation.php index 74e20b3..f3c0dc5 100644 --- a/Classes/FusionObjects/AssetImageSourceImplementation.php +++ b/Classes/FusionObjects/AssetImageSourceImplementation.php @@ -5,7 +5,7 @@ use Neos\Flow\ResourceManagement\ResourceManager; use Sitegeist\Kaleidoscope\EelHelpers\ImageSourceHelperInterface; use Sitegeist\Kaleidoscope\EelHelpers\AssetImageSourceHelper; -use Neos\Fusion\FusionObjects\AbstractFusionObject; +use Sitegeist\Kaleidoscope\EelHelpers\UriImageSourceHelper; class AssetImageSourceImplementation extends AbstractImageSourceImplementation { diff --git a/Classes/FusionObjects/DummyImageSourceImplementation.php b/Classes/FusionObjects/DummyImageSourceImplementation.php index 5fd2270..3651606 100644 --- a/Classes/FusionObjects/DummyImageSourceImplementation.php +++ b/Classes/FusionObjects/DummyImageSourceImplementation.php @@ -4,7 +4,6 @@ use Neos\Flow\Annotations as Flow; use Sitegeist\Kaleidoscope\EelHelpers\ImageSourceHelperInterface; use Sitegeist\Kaleidoscope\EelHelpers\DummyImageSourceHelper; -use Neos\Fusion\FusionObjects\AbstractFusionObject; class DummyImageSourceImplementation extends AbstractImageSourceImplementation { diff --git a/Classes/FusionObjects/UriImageSourceImplementation.php b/Classes/FusionObjects/UriImageSourceImplementation.php index 19965da..45f1b2e 100644 --- a/Classes/FusionObjects/UriImageSourceImplementation.php +++ b/Classes/FusionObjects/UriImageSourceImplementation.php @@ -3,7 +3,6 @@ use Neos\Flow\Annotations as Flow; use Sitegeist\Kaleidoscope\EelHelpers\ImageSourceHelperInterface; -use Sitegeist\Kaleidoscope\EelHelpers\ResourceImageSourceHelper; use Neos\Fusion\FusionObjects\AbstractFusionObject; use Sitegeist\Kaleidoscope\EelHelpers\UriImageSourceHelper;