From 8cb94f0b5c37df70624453ca0a7a1b8269f8973b Mon Sep 17 00:00:00 2001 From: Dave Cranwell Date: Fri, 20 Jun 2014 13:46:43 +0100 Subject: [PATCH] Update frontenddevelopers.rst Added notes about new image manipulation techniques --- .../building_your_site/frontenddevelopers.rst | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/docs/building_your_site/frontenddevelopers.rst b/docs/building_your_site/frontenddevelopers.rst index a8cf6a25e..bb12c5922 100644 --- a/docs/building_your_site/frontenddevelopers.rst +++ b/docs/building_your_site/frontenddevelopers.rst @@ -186,7 +186,24 @@ The available resizing methods are: More control over the ``img`` tag --------------------------------- -In some cases greater control over the ``img`` tag is required, for example to add a custom ``class``. Rather than generating the ``img`` element for you, Wagtail can assign the relevant data to another object using Django's ``as`` syntax: +Greater control over the ``img`` tag is often required, for example to add a custom ``class``. This can be most easily achieved in two ways: + +.. versionadded:: 0.4 + +Adding attributes to the {% image %} tag +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Simply add extra attributes with the syntax ``attribute="value"`` to the tag: + +.. code-block:: django + + {% image self.photo width-400 class="foo" id="bar" %} + + +Generating the image "as" +~~~~~~~~~~~~~~~~~~~~~~~~~ + +Wagtail can assign the image data to another object using Django's ``as`` syntax: .. code-block:: django @@ -197,12 +214,17 @@ In some cases greater control over the ``img`` tag is required, for example to a {{ tmp_photo.alt }} + +The ``attrs`` shortcut +----------------------- + You can also use the ``attrs`` property as a shorthand to output the ``src``, ``width``, ``height`` and ``alt`` attributes in one go: .. code-block:: django + .. _rich-text-filter: Rich text (filter)