Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Wagtail SB ImageSerializer

Wagtail package to render images with rendition in a single API Field.

Community-Project

Wagtail package to render images with rendition in a single API Field.

✨ Features¢

πŸ“‹ RequirementsΒΆ

πŸ“¦ InstallationΒΆ

Using pipΒΆ

pip install wagtail-sb-imageserializer

Using uvΒΆ

uv add wagtail-sb-imageserializer

πŸš€ UsageΒΆ

Add wagtail.api.v2, rest_framework and wagtail_sb_imageserializer to your INSTALLED_APPS settings:

INSTALLED_APPS = [
  # ...
  "wagtail.api.v2",
  "rest_framework",
  "wagtail_sb_imageserializer",
  # ...
]

In your model specify the ImageSerializerField as serializer for the APIField related to the image field and add the renditions parameter with the renditions you want to render.

from wagtail.models import Page
from wagtail.api import APIField
from wagtail_sb_imageserializer.fields import ImageSerializerField

class SamplePage(Page):
    image = ImageSerializerField()

    api_fields = [
        APIField(
          "image",
          serializer=ImageSerializerField(
              renditions={
                  "lazy": "fill-50x50",
                  "mobile": "fill-128x128",
                  "tablet": "fill-256x256",
                  "desktop": "fill-512x512",
              }
          ),
        ),
    ]

πŸ› οΈ DevelopmentΒΆ

Check out our Contribution Guide for details on setting up your development environment, running tests, and submitting pull requests.

The project uses uv for dependency management, ruff for linting, and tox for multi-environment testing.

πŸ“œ ChangelogΒΆ

See the CHANGELOG.md for a history of changes.

πŸ‘₯ ContributorsΒΆ

See our list of contributors.

πŸ“„ LicenseΒΆ

This project is licensed under the Apache License 2.0. See the LICENSE file for details.