Imagine Bundle and AssetMapper
Discussed in https://github.com/liip/LiipImagineBundle/discussions/1605
Originally posted by ebitkov August 19, 2024
The current recommendation to handle assets is to use the AssetMapper component (https://symfony.com/doc/current/frontend/asset_mapper.html), which integrates with the Twig asset function and automatically adds versioning to images.
As stated in the documentation, the bundle should automatically detect the versioning and handle it: https://symfony.com/bundles/LiipImagineBundle/current/asset-versioning.html.
But for me it seems not to do it. I get a "404 - Source image for path could not be found" error.
So I'm wondering: Does this bundle support the new AssetMapper component? And if yes, am I the only one, who has problem with it?
As described in the discussion above, Symfony recommends the relative new AssetMapper component as the preferred way to handle your assets, especially for new projects. The documentation of the Imagine Bundle describes, that it supports asset versioning, but I noticed, that the AssetMapper component is currently not supported.
When using AssetMapper, accessing a file via the asset Twig function and then applying a filter on it results in a 404 - source image for path could not be found error.
Here is a simple reproducer to test with: https://github.com/ebitkov/liip-imagine-bundle-and-asset-mapper
I've tried to add
loaders:
default:
filesystem:
data_root:
- '%kernel.project_dir%/public'
- '%kernel.project_dir%/assets/images'
but it didn't work
I ran into the same issue, was this ever resolved?
As a workaround, one can run php bin/console asset-map:compile to temporarily resolve the issue
i think the asset versioning of this bundle predates those newer changes. glad if somebody has time to sort it out and propose fixes / documentation updates. (i don't have much time to invest into this bundle at the moment, unfortunately)