symfony-docs
symfony-docs copied to clipboard
A question on the AssetMapper component
Hi there,
Here's a question on the AssetMapper component just in case the following issue is not documented.
I was wondering if it is possible to "compile" the assets without versioning the files so that the file names generated in the public folder are still the exact same ones as in the asset folder.
Please correct me if wrong, this way the assets could be referenced in Markdown files. See https://github.com/twigphp/Twig/discussions/4070
Thanks for the help.
No it's not possible for now sorry
What about using a command option?
php bin/console asset-map:compile --unversioned
If you need to deploy unversionned asset you still can use the Asset component !
Sorry, I wasn't able to find any documentation on how to "compile" the assets so that the hash won't be appended to the filenames. Can you please provide an example command for this?
🙏 Thank you!
If you need to compile assets via asset mapper, today you cannot escape versionning. If you need to deploy assets to the public folder, the Asset package can do it for you.
https://symfony.com/doc/current/components/asset.html
But if your problem is related to the markdown example you gave, there is a better solution i think : render the twig file once and then call the markdown filter
So let's say you have a article.md.twig
# Title of your article
Lorem ipsum damet
[{{ article.alt }}]({{ absolute_url(asset('images/my-file.png')) }})
In another template, you can do this:
{% set content = include('article.md.html') %}
{% apply markdown_to_html %}
{{ content }}
{% endapply %}
Thanks for the help, it is very much appreciated! I just created a folder called public/blog
for my static blog images. It seems as if the simplest solution is to put the blog images in the public directory as opposed to the assets directory for them to then be referenced in the Markdown documents. See templates/post.html.twig
Let's close this one as "fixed" because it looks like a particular use-case and some clues and guidelines were provided. Thanks!