Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2e649b3

Browse files
committed
Merge pull requestsymfony#3230 from peterkokot/patch-assetic-image
Image assetic management
2 parents1a425cc +b5ca005 commit2e649b3

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)

[8]ページ先頭

©2009-2025 Movatter.jp