Closed FDiskas closed 3 years ago
After re uploading product image file as simple png it fixes the issue.
Thanks for finding this restriction. This problem is due to the fact that the liip bundle (which is used to generate the product images) can not handle svg images.
After re uploading product image file as simple png it fixes the issue.
Hello, I have the same problem (exact same) but all of my image are jpg. How could I fix that ?
@robin-aeist Your problem is a little bit different as jpg files should be properly handled by liip bundle.
This does not work when the SVG is stored in cloud storage (e.g. S3). In case someone else encounters this issue, this is how we resolved it:
final class LiipImageFiltersPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container): void
{
$useDefaultFilterExtension = new Definition(FilterExtension::class);
$useDefaultFilterExtension->setArguments([new Reference('liip_imagine.cache.manager')]);
$useDefaultFilterExtension->addTag('twig.extension');
$container->setDefinition('liip_imagine.templating.filter_extension', $useDefaultFilterExtension);
}
}
public function build(ContainerBuilder $container): void
{
$container->addCompilerPass(new LiipImageFiltersPass());
}
use Liip\ImagineBundle\Binary\BinaryInterface;
use Liip\ImagineBundle\Imagine\Filter\FilterManager as BundleFilterManager;
use Liip\ImagineBundle\Model\Binary;
final class FilterManager extends BundleFilterManager { public function apply(BinaryInterface $binary, array $config): BinaryInterface { $config += [ 'quality' => 100, 'animated' => false, ];
if ($binary->getFormat() === 'svg') {
$svgBinary = new Binary($binary->getContent(), 'image/svg+xml', $binary->getFormat());
return $this->applyPostProcessors($svgBinary, $config);
}
return $this->applyPostProcessors($this->applyFilters($binary, $config), $config);
}
}
4. And registered this in services.yaml
```yaml
liip_imagine.filter.manager:
class: App\Service\Liip\FilterManager
arguments:
- "@liip_imagine.filter.configuration"
- "@liip_imagine"
- "@liip_imagine.binary.mime_type_guesser"
And voila, SVGs are supported no matter the place where they are stored.
If I request the endpoint
http://localhost/shop-api/product-latest/
I got the flowing errorSteps to reproduce:
http://localhost/shop-api/product-latest/
As far as I understand svg is with embeded png
Sample image
e0fe3450b896642e5efb574872a3.zip