Social Networks settings for wagtail sites.
Project description
Wagtail Image Serializer
Wagtail package to render images with rendition in a single API Field.
Requirements
- Python 3.8.1 or higher
- Wagtail 3.0 or higher
- Django 3.2 or higher
- Django Rest Framework 3.13 or higher
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
Built Distribution
File details
Details for the file wagtail_sb_imageserializer-0.4.0.tar.gz
.
File metadata
- Download URL: wagtail_sb_imageserializer-0.4.0.tar.gz
- Upload date:
- Size: 4.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.11.4 Linux/5.15.0-73-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 45d5b7311df9893c283766bf1933059de04a4ed003d369d06b23de6a0fc28545 |
|
MD5 | b31e4da851f058379fd3d2026ebfe4a8 |
|
BLAKE2b-256 | a0d4b98ad1e7158b46e91f7000a289060598e89661c72e2e24dc4da6030b6119 |
File details
Details for the file wagtail_sb_imageserializer-0.4.0-py3-none-any.whl
.
File metadata
- Download URL: wagtail_sb_imageserializer-0.4.0-py3-none-any.whl
- Upload date:
- Size: 7.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.11.4 Linux/5.15.0-73-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 89b59fc55dc3c456746319b34ffcad9c037836c8734b58fd14e7af2609b537d6 |
|
MD5 | c3b72c96ef92eb2c2a960f8ea1f083f4 |
|
BLAKE2b-256 | fad1e3bd6328d5fe0aaa27350be36555dc504dae3ea18d35da64b3adbc0a066e |