Django REST Framework

Requires the drf extra. See Django REST Framework for installation, configuration, and usage.

class imgproxykit.integrations.drf.ImgproxyURLField(*, transform: Transform | str | None = None, **kwargs: Any)[source]

Represent a source string or model file as a read-only imgproxy URL.

Use Django’s IMGPROXYKIT settings without request context. Empty sources return None without calling the source resolver. read_only must be True and write_only must be False.

Parameters:
transform: Transform | str | None = None

Transformation or name from IMGPROXYKIT['transforms']. Omit to add no processing options.

**kwargs: Any

DRF field options. allow_null defaults to True.

Configure the transformation and DRF field options.

class imgproxykit.integrations.drf.ImgproxyVariantsField(*, variants: Mapping[str, Transform] | str, **kwargs: Any)[source]

Represent a source as a read-only dictionary of named imgproxy URLs.

Use Django’s IMGPROXYKIT settings and resolve the source once for all variants. Empty sources return None without calling the resolver. read_only must be True and write_only must be False. child cannot be supplied; variant values always use a URL field.

Parameters:
variants: Mapping[str, Transform] | str

Transformation mapping or set name from IMGPROXYKIT['variants'].

**kwargs: Any

DRF field options. allow_null defaults to True.

Configure the variants and DRF field options.