mirror of
https://github.com/wagtail/wagtail.git
synced 2024-11-28 08:48:04 +01:00
Update frontenddevelopers.rst
This commit is contained in:
parent
c1f2f745af
commit
135d4f20a6
@ -186,34 +186,32 @@ The available resizing methods are:
|
||||
More control over the ``img`` tag
|
||||
---------------------------------
|
||||
|
||||
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:
|
||||
Wagtail provides two shorcuts to gain grater greater control over the ``img`` element:
|
||||
|
||||
.. versionadded:: 0.4
|
||||
|
||||
**Adding attributes to the {% image %} tag**
|
||||
|
||||
Simply add extra attributes with the syntax ``attribute="value"`` to the tag:
|
||||
Extra attributes can be specified with the syntax ``attribute="value"``:
|
||||
|
||||
.. code-block:: django
|
||||
|
||||
{% 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.
|
||||
|
||||
|
||||
**Generating the image "as"**
|
||||
|
||||
|
||||
Wagtail can assign the image data to another object using Django's ``as`` syntax:
|
||||
|
||||
.. code-block:: django
|
||||
|
||||
{% load image %}
|
||||
...
|
||||
{% image self.photo width-400 as tmp_photo %}
|
||||
|
||||
<img src="{{ tmp_photo.src }}" width="{{ tmp_photo.width }}"
|
||||
height="{{ tmp_photo.height }}" alt="{{ tmp_photo.alt }}" class="my-custom-class" />
|
||||
|
||||
|
||||
.. versionadded:: 0.4
|
||||
The ``attrs`` shortcut
|
||||
-----------------------
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user