8000 [Feature Request] Absolute asset URL · Issue #5322 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Feature Request] Absolute asset URL #5322

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

Closed
marcospassos opened this issue Aug 22, 2012 · 10 comments
Closed

[Feature Request] Absolute asset URL #5322

marcospassos opened this issue Aug 22, 2012 · 10 comments
Labels
Good first issue Ideal for your first contribution! (some Symfony experience may be required) Templating

Comments

@marcospassos
Copy link

Hey guys!

Currently, there's no standard way of retrieving the absolute URL to an asset. This would be useful when generating asset paths in a template for an email. Would be cool a function like:

{{ asset_url('images/foo.jpg') }}

The current solution is not pratical and breaks when using CDN.

Thanks,
Marcos

@willdurand
Copy link
Contributor

@stof
Copy link
Member
stof commented Aug 22, 2012

@willdurand the issue is that it will make all asset url absolute, even when not really needed. and it will make it more difficult for the dev setup, as each dev will have to change the config according to the base url he has locally. So this solution is not a perfect one either.
Btw, I think this feature request is a duplicate (but I'm lazy searching the older one right now)

@marcospassos
Copy link
Author

@stof Exactly, this is fundamental for many things.

@webda2l
Copy link
webda2l commented Aug 23, 2012

For now, you can do : {{ app.request.getSchemeAndHttpHost ~ asset('images/foo.jpg') }}

One of the other duplicate issues : #3056

@Schyzophrenic
Copy link

I have the same issue.
The problem is that you don't have to the request when sending email through a console command.

I would have liked to avoid having a specific parameter in my config.yml just for this purpose (as it now works for url as in 2.1).
Any other workaround ?

@kingcrunch
Copy link
Contributor

@stof You can set assets-base-url in your config_prod.yml only. Also "it is not really required" is not really an argument ;) Many use a separate domains for their assets anyway. I think it is a solution.

< 8000 /form>

@inoryy
Copy link
Contributor
inoryy commented Apr 17, 2013

I'll take a stab at it

@lavoiesl
Copy link
Contributor

Or even:

{{ app.request.getUriForPath('') ~ asset('images/foo.jpg') }}

@stof
Copy link
Member
stof commented Apr 9, 2014

Implemented in #10451

@stof stof closed this as completed Apr 9, 2014
@homersimpsons
Copy link
Contributor

Hum ... Sorry for re-opening this old thread but this seems to get removed in https://github.com/symfony/symfony/blob/master/src/Symfony/Bridge/Twig/Extension/AssetExtension.php#L54
How can I achieve this gracefully ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Good first issue Ideal for your first contribution! (some Symfony experience may be required) Templating
Projects
None yet
Development

No branches or pull requests

9 participants
0