Skip to content

Commit b5ca005

Browse files
committed
image tag for assetic management added and fixed a typo
1 parent f14ef95 commit b5ca005

File tree

2 files changed

+30
-3
lines changed

2 files changed

+30
-3
lines changed

cookbook/assetic/asset_management.rst

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,9 @@ Using Assetic provides many advantages over directly serving the files.
4343
The files do not need to be stored where they are served from and can be
4444
drawn from various sources such as from within a bundle.
4545

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
4849
behind adding either is basically the same, but with a slightly different syntax.
4950

5051
.. _cookbook-assetic-including-javascript:
@@ -128,6 +129,32 @@ the :ref:`cssrewrite <cookbook-assetic-cssrewrite>` filter.
128129
that there is a known issue that causes the ``cssrewrite`` filter to fail
129130
when using the ``@AcmeFooBundle`` syntax for CSS Stylesheets.
130131

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+
131158
.. _cookbook-assetic-cssrewrite:
132159

133160
Fixing CSS Paths with the ``cssrewrite`` Filter

cookbook/assetic/jpeg_optimize.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ It can now be used from a template:
6464

6565
.. code-block:: html+php
6666

67-
<?php foreach ($view['assetic']->images(
67+
<?php foreach ($view['assetic']->image(
6868
array('@AcmeFooBundle/Resources/public/images/example.jpg'),
6969
array('jpegoptim')
7070
) as $url): ?>

0 commit comments

Comments
 (0)