Skip to content

Commit 9589301

Browse files
committed
Resolve #33 -- Add documentation for aspect ratios
1 parent 812e86d commit 9589301

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,38 @@ if get_settings().USE_PLACEHOLDERS:
103103

104104
### Config
105105

106+
#### Aspect ratios
107+
108+
You can specify the aspect ratios of your images. Images will be cropped to the
109+
specified aspect ratio. Aspect ratios are specified as a string with a slash
110+
between the width and height. For example, `16/9` will crop the image to 16:9.
111+
112+
```python
113+
# models.py
114+
from django.db import models
115+
from pictures.models import PictureField
116+
117+
118+
class Profile(models.Model):
119+
title = models.CharField(max_length=255)
120+
picture = PictureField(
121+
upload_to="avatars",
122+
aspect_ratios=[None, "1/1", "3/2", "16/9"],
123+
)
124+
```
125+
126+
```html
127+
# template.html
128+
{% load pictures %}
129+
{% picture profile.picture alt="Spiderman" ratio="16/9" m=6 l=4 %}
130+
```
131+
132+
If you don't specify an aspect ratio or None in your template, the image will be
133+
served with the original aspect ratio of the file.
134+
135+
You may only use aspect ratios in templates, that have been defined on the model.
136+
The model `aspect_ratios` will default to `[None]`, if other value is provided.
137+
106138
#### Breakpoints
107139

108140
You may define your own breakpoints, they should be identical to the ones used

0 commit comments

Comments
 (0)