8000 Return "version" argument to "asset" function · Issue #14958 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Return "version" argument to "asset" function #14958

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
Koc opened this issue Jun 12, 2015 · 11 comments
Closed

Return "version" argument to "asset" function #14958

Koc opened this issue Jun 12, 2015 · 11 comments

Comments

@Koc
Copy link
Contributor
Koc commented Jun 12, 2015

http://symfony.com/doc/current/reference/configuration/framework.html#assets-version-format

Some CDN's do not support cache-busting via query strings, so injecting the version into the actual file path is necessary. Thankfully, assets_version_format is not limited to producing versioned query strings.

The pattern receives the asset's original path and version as its first and second parameters, respectively. Since the asset's path is one parameter, you cannot modify it in-place (e.g. /images/logo-v5.png); however, you can prefix the asset's path using a pattern of version-%%2$s/%%1$s, which would result in the path version-5/images/logo.png.

symfony/symfony-docs#4982

{# absolute URLs - get the version with asset_version() and append it manually #}
{{ absolute_url(asset('logo.png')) ~ '?' ~ asset_version('logo.png') }}

Proposed solution doesn't respect assets_version_format but previous asset('logo.png', version=5) does.

@stof
Copy link
Member
stof commented Jun 12, 2015

I don't understand what you are asking here. The title of the issue and the description seem to be related to 2 different things

@Koc
Copy link
Contributor Author
Koc commented Jun 14, 2015

Description demonstrates that this argument is really needed.

@jakzal jakzal added the Asset label Jul 6, 2015
@xabbuh
Copy link
Member
xabbuh commented Jan 23, 2016

The example in the description could still be achieved with something like the following if I don't miss anything:

<img src="version-{{ asset_version('package_name) }}{{ asset('logo.png') }}">

@Koc
Copy link
Contributor Author
Koc commented Jan 24, 2016

So if I would change assets version format I should rewrite all of the templates according to the new format. Not so useful

@wouterj
Copy link
Member
wouterj commented Jan 24, 2016

According to http://symfony.com/blog/new-in-symfony-2-7-the-new-asset-component, you can configure the version format and version in the asset configuration and it will automatically be appended when using asset().

@Koc
Copy link
Contributor Author
Koc commented Jan 25, 2016

What to do if I want specify version of concrete asset? In this case I should use concatenation

@javiereguiluz
Copy link
Member

I'd close this as "won't fix" because:

  • If this only affects to a handful of assets, then concatenating the version should not be a big deal.
  • If it affects to lots of your assets, then you can define a package for them.

@Koc
Copy link
Contributor Author
Koc commented Feb 23, 2017

@javiereguiluz have you seen referenced commit above? Is it acceptable? If yes I can finish it and open PR

@Koc
Copy link
Contributor Author
Koc commented Feb 23, 2017

concatenation ois not possible with specific version format.

@nicolas-grekas
Copy link
Member

@Koc can't this be achieved using a custom versioning strategy? did you give it a try? Shall we close otherwise?

@Koc
Copy link
Contributor Author
Koc commented Oct 2, 2018

I don't need this feature anymore :)

@Koc Koc closed this as completed Oct 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants
0