Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A question on the AssetMapper component #19863

Closed
programarivm opened this issue May 6, 2024 · 7 comments
Closed

A question on the AssetMapper component #19863

programarivm opened this issue May 6, 2024 · 7 comments

Comments

@programarivm
Copy link

programarivm commented May 6, 2024

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 twigphp/Twig#4070

Thanks for the help.

@smnandre
Copy link
Contributor

smnandre commented May 8, 2024

No it's not possible for now sorry

@programarivm
Copy link
Author

What about using a command option?

php bin/console asset-map:compile --unversioned

@smnandre
Copy link
Contributor

If you need to deploy unversionned asset you still can use the Asset component !

@programarivm
Copy link
Author

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!

@smnandre
Copy link
Contributor

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 %}   

@programarivm
Copy link
Author

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

@javiereguiluz
Copy link
Member

Let's close this one as "fixed" because it looks like a particular use-case and some clues and guidelines were provided. Thanks!

@javiereguiluz javiereguiluz closed this as not planned Won't fix, can't repro, duplicate, stale Jun 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants