File tree Expand file tree Collapse file tree 3 files changed +104
-71
lines changed
Filter options
components/templating/helpers Expand file tree Collapse file tree 3 files changed +104
-71
lines changed
Original file line number Diff line number Diff line change @@ -991,6 +991,22 @@ assets won't be cached when deployed. For example, ``/images/logo.png`` might
991
991
look like ``/images/logo.png?v2 ``. For more information, see the :ref: `ref-framework-assets-version `
992
992
configuration option.
993
993
994
+ .. versionadded :: 2.5
995
+ Absolute URLs for assets were introduced in Symfony 2.5.
996
+
997
+ If you need absolute URLs for assets, you can set the third argument (or the
998
+ ``absolute `` argument) to ``true ``:
999
+
1000
+ .. configuration-block ::
1001
+
1002
+ .. code-block :: html+jinja
1003
+
1004
+ <img src="{{ asset('images/logo.png', absolute=true) }}" alt="Symfony!" />
1005
+
1006
+ .. code-block :: html+php
1007
+
1008
+ <img src="<?php echo $view['assets']->getUrl('images/logo.png', null, true) ?>" alt="Symfony!" />
1009
+
994
1010
.. index ::
995
1011
single: Templating; Including stylesheets and JavaScripts
996
1012
single: Stylesheets; Including stylesheets
Original file line number Diff line number Diff line change @@ -47,6 +47,23 @@ You can also specify a URL to use in the second parameter of the constructor::
47
47
48
48
Now URLs are rendered like ``http://cdn.example.com/images/logo.png ``.
49
49
50
+ .. versionadded :: 2.5
51
+ Absolute URLs for assets were introduced in Symfony 2.5.
52
+
53
+ You can also use the third argument of the helper to force an absolute URL:
54
+
55
+ .. code-block :: html+php
56
+
57
+ <img src="<?php echo $view['assets']->getUrl('images/logo.png', null, true) ?>">
58
+ <!-- renders as:
59
+ <img src="http://yourwebsite.com/foo/bar/images/logo.png">
60
+ -->
61
+
62
+ .. note ::
63
+
64
+ If you already set a URL in the constructor, using the third argument of
65
+ ``getUrl `` will not affect the generated URL.
66
+
50
67
Versioning
51
68
----------
52
69
You can’t perform that action at this time.
0 commit comments