Docs for format and jpegquality image filters

This also fixes #1205
pull/3053/head
Karl Hobley 2016-05-03 15:23:37 +01:00 zatwierdzone przez Matt Westcott
rodzic 43e0b9d237
commit 6c57b5b280
1 zmienionych plików z 73 dodań i 13 usunięć

Wyświetl plik

@ -70,7 +70,7 @@ The available resizing methods are as follows:
{% image page.photo height-480 %}
Resize the height of the image to the dimension specified..
Resize the height of the image to the dimension specified.
``fill``
(takes two dimensions and an optional ``-c`` parameter)
@ -197,3 +197,63 @@ Wagtail comes with three pre-defined image formats, but more can be defined in P
The CSS classes added to images do **not** come with any accompanying stylesheets, or inline styles. e.g. the ``left`` class will do nothing, by default. The developer is expected to add these classes to their front end CSS files, to define exactly what they want ``left``, ``right`` or ``full-width`` to mean.
For more information about image formats, including creating your own, see :ref:`rich_text_image_formats`
Output image format
-------------------
Wagtail may automatically change the format of some images when they are resized:
- PNG and JPEG images always won't change format
- GIF images without animation are converted to PNGs
- BMP images are always converted to PNGs
It is also possible to override the output format on a per-tag basis by using the
``format`` filter after the resize rule.
For example, to make the tag always convert the image to a JPEG, use ``format-jpeg``:
.. code-block:: html+Django
{% image page.photo width-400 format-jpeg %}
You may also use ``format-png`` or ``format-gif``.
JPEG image quality
------------------
Wagtail's JPEG image quality setting defaults to 85 (which is quite high). This
can be changed either globally or on a per-tag basis.
Changing globally
^^^^^^^^^^^^^^^^^
Use the ``WAGTAILIMAGES_JPEG_QUALITY`` setting to change the global default JPEG
quality:
.. code-block:: python
# settings.py
# Make low-quality but small images
WAGTAILIMAGES_JPEG_QUALITY = 40
Note that this won't affect any previously generated images. You may want to
delete all renditions so they can regenerate with the new setting.
Changing per-tag
^^^^^^^^^^^^^^^^
It's also possible to have different JPEG qualities on individual tags by using
the ``jpegquality`` filter. This will always override the default setting:
.. code-block:: html+Django
{% image page.photo width-400 jpegquality-40 %}
Note that this will have no effect on PNG or GIF files. If you want all images
to be low quality, you can use this filter with ``format-jpeg`` (which forces
all images to output in JPEG format):
.. code-block:: html+Django
{% image page.photo width-400 format-jpeg jpegquality-40 %}