Different type of field are as followed:-
- max (takes two dimensions)
{%
image page.photo max-1000x500 %}
- min (takes two dimensions)
{% image page.photo min-500x200 %}
- width (takes one dimension)
{% image page.photo width-640 %}
- height (takes one dimension)
{% image page.photo height-480 %}
{% image page.photo scale-50 %}
- fill (takes two dimensions and an optional -c parameter)
{% image page.photo fill-200x200 %}
- original (takes no dimensions)
{% image page.photo original %}
More control over the img tag
1. Adding attributes to the {% image %} tag
{% image page.photo width-400 class="foo" id="bar" %}
2. Generating the image "as foo" to access individual properties
{% image page.photo width-400 as tmp_photo %}
<img src="{{ tmp_photo.url }}" width="{{ tmp_photo.width }}"
height="{{ tmp_photo.height }}" alt="{{ tmp_photo.alt }}" class="my-custom-class"
The attrs shortcut
You can also use the attrs property as a shorthand to output the attributes src, width , height and alt in one go
<img {{ tmp_photo.attrs }} class="my-custom-class" />
Comments