References to image.src corrected - it's image.url

stable/0.4.x
Dave Cranwell 2014-07-10 11:47:40 +01:00
rodzic 2cc8629ab4
commit bd1c72c0aa
1 zmienionych plików z 10 dodań i 5 usunięć

Wyświetl plik

@ -202,26 +202,31 @@ Extra attributes can be specified with the syntax ``attribute="value"``:
{% image self.photo width-400 class="foo" id="bar" %}
No validation is performed on attributes add in this way by the developer. It's possible to add `src`, `width`, `height` and `alt` of your own that might conflict with those generated by the tag itself.
No validation is performed on attributes added in this way so it's possible to add `src`, `width`, `height` and `alt` of your own that might conflict with those generated by the tag itself.
**Generating the image "as"**
**Generating the image "as foo" to access individual properties **
Wagtail can assign the image data to another object using Django's ``as`` syntax:
Wagtail can assign the image data to another variable using Django's ``as`` syntax:
.. code-block:: django
{% image self.photo width-400 as tmp_photo %}
<img src="{{ tmp_photo.src }}" width="{{ tmp_photo.width }}"
<img src="{{ tmp_photo.url }}" width="{{ tmp_photo.width }}"
height="{{ tmp_photo.height }}" alt="{{ tmp_photo.alt }}" class="my-custom-class" />
.. Note::
The image property used for the `src` attribute is actually `image.url`, not `image.src`.
The ``attrs`` shortcut
-----------------------
.. versionadded:: 0.4
You can also use the ``attrs`` property as a shorthand to output the ``src``, ``width``, ``height`` and ``alt`` attributes in one go:
You can also use the ``attrs`` property as a shorthand to output the attributes ``src``, ``width``, ``height`` and ``alt`` in one go:
.. code-block:: django