@@ -43,8 +43,9 @@ Using Assetic provides many advantages over directly serving the files.
43
43
The files do not need to be stored where they are served from and can be
44
44
drawn from various sources such as from within a bundle.
45
45
46
- You can use Assetic to process both :ref: `CSS stylesheets <cookbook-assetic-including-css >`
47
- and :ref: `JavaScript files <cookbook-assetic-including-javascript >`. The philosophy
46
+ You can use Assetic to process :ref: `CSS stylesheets <cookbook-assetic-including-css >`,
47
+ :ref: `JavaScript files <cookbook-assetic-including-javascript >` and
48
+ :ref: `images <cookbook-assetic-including-image >`. The philosophy
48
49
behind adding either is basically the same, but with a slightly different syntax.
49
50
50
51
.. _cookbook-assetic-including-javascript :
@@ -128,6 +129,32 @@ the :ref:`cssrewrite <cookbook-assetic-cssrewrite>` filter.
128
129
that there is a known issue that causes the ``cssrewrite `` filter to fail
129
130
when using the ``@AcmeFooBundle `` syntax for CSS Stylesheets.
130
131
132
+ .. _cookbook-assetic-including-image :
133
+
134
+ Including images
135
+ ~~~~~~~~~~~~~~~~
136
+
137
+ To include an image you can use the ``image `` tag.
138
+
139
+ .. configuration-block ::
140
+
141
+ .. code-block :: html+jinja
142
+
143
+ {% image '@AcmeFooBundle/Resources/public/images/example.jpg' %}
144
+ <img src="{{ asset_url }}" alt="Example" />
145
+ {% endimage %}
146
+
147
+ .. code-block :: html+php
148
+
149
+ <?php foreach ($view['assetic']->image(
150
+ array('@AcmeFooBundle/Resources/public/images/example.jpg')
151
+ ) as $url): ?>
152
+ <img src="<?php echo $view->escape($url) ?>" alt="Example" />
153
+ <?php endforeach; ?>
154
+
155
+ You can also use Assetic for image optimization. More information in
156
+ :doc: `/cookbook/assetic/jpeg_optimize `.
157
+
131
158
.. _cookbook-assetic-cssrewrite :
132
159
133
160
Fixing CSS Paths with the ``cssrewrite `` Filter
0 commit comments