File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -219,6 +219,26 @@ The default processor is `pictures.tasks.process_picture`. It takes a single
219219argument, the ` PictureFileFile ` instance. You can use this to override the
220220processor, should you need to do some custom processing.
221221
222+ ### Validators
223+
224+ The library includes built-in validators to control image dimensions:
225+
226+ ``` python
227+ from pictures.models import PictureField
228+ from pictures.validators import MaxSizeValidator, MinSizeValidator
229+
230+ class Profile (models .Model ):
231+ picture = PictureField(
232+ upload_to = " avatars" ,
233+ validators = [
234+ MinSizeValidator(400 , 300 ), # At least 400x300 pixels
235+ MaxSizeValidator(4096 , 4096 ), # At most 4096x4096 pixels
236+ ]
237+ )
238+ ```
239+
240+ Use ` None ` to limit only one dimension: ` MaxSizeValidator(2048, None) ` limits only width.
241+
222242## Migrations
223243
224244Django doesn't support file field migrations, but we do.
You can’t perform that action at this time.
0 commit comments