Skip to main content

Social Networks settings for wagtail sites.

Project description

Community-Project

PyPI - Supported versions PyPI - Package version PyPI - Downloads PyPI - MIT License

Codacy Badge

Wagtail Image Serializer

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

Requirements

  • Python 3.8.1 or higher
  • Django lower than 4.0
  • Wagtail lower than 6.0
  • Django Rest Framework lower than 4.0

Install

pip install 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",
              }
          ),
        ),
    ]

When yo require your page from the API, the image filed will looks like this

{
    "id": 1234567890,
    "meta": {
        "type": "wagtailimages.Image",
        "title": "Image title",
        "alt": "Image alt text"
    },
    "original": {
        "width": 123456788890,
        "height": 123456788890,
        "download_url": "https://your-cdn-domain/path/to/original_images/image_name.png"
    },
    "renditions": {
        "lazy": {
            "width": 50,
            "height": 50,
            "download_url": "https://your-cdn-domain/path/to/reditions/image_name.fill-50x50.png"
        },
        "mobile": {
            "width": 128,
            "height": 128,
            "download_url": "https://your-cdn-domain/path/to/reditions/image_name.fill-128x128.png"
        },
        "tablet": {
            "width": 256,
            "height": 256,
            "download_url": "https://your-cdn-domain/path/to/reditions/image_name.fill-256x256.png"
        },
        "desktop": {
            "width": 512,
            "height": 512,
            "download_url": "https://your-cdn-domain/path/to/reditions/image_name.fill-512x512.png"
        }
    }
},

Docs

Changelog

All changes to versions of this library are listed in the change history.

Development

Check out our contribution guide.

Contributors

See the list of contributors here.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wagtail_sb_imageserializer-0.3.0.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file wagtail_sb_imageserializer-0.3.0.tar.gz.

File metadata

  • Download URL: wagtail_sb_imageserializer-0.3.0.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.10.12 Linux/5.15.0-73-generic

File hashes

Hashes for wagtail_sb_imageserializer-0.3.0.tar.gz
Algorithm Hash digest
SHA256 ba86465e65192035ccd76de0db1ac1c1382228ad3cf3bec0163765dca8466253
MD5 c9329aac9663a735e008dc225631b444
BLAKE2b-256 81202f0e15667624364dec3a637c015a919320bdf3779fb7402f70800fd1bd04

See more details on using hashes here.

File details

Details for the file wagtail_sb_imageserializer-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for wagtail_sb_imageserializer-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c6f66d6fefb8173996f59c14140f05a6ef1659cd9d2fdb3b41fa1cd4560f6682
MD5 3ce5defbb493c7148d531b3bc91c9e34
BLAKE2b-256 78c743edd505af95e84eee46344e1b12dbf91fbc7af47e4521634c9ced160e44

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page