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
Closed
@Koc

Description

@Koc

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0