Adds ability to use placeholder images for local development
Project description
wagtial placeholder images
This is a package for using placeholder images when developing which can be useful if you're storing them on a server and don't want to download them or link directly to the server when working locally.
Installation
First download the package:
pip install wagtail-placeholder-images
Then there's two options. If you're using your own custom image model you can use PlaceholderRenditionMixin
like so:
from wagtail.images.models import AbstractImage
from wagtail_placeholder_images.mixins import PlaceholderRenditionMixin
class CustomImage(PlaceholderRenditionMixin, AbstractImage):
admin_form_fields = Image.admin_form_fields + (
# Then add the field names here to make them appear in the form:
# 'caption',
)
If you're using the standard Wagtail Image model you can monkey patch it:
from wagtail.images.models import AbstractImage
from wagtail_placeholder_images.mixins import PlaceholderRenditionMixin
AbstractImage.get_placeholder_rendition = PlaceholderRenditionMixin.get_placeholder_rendition
AbstractImage.get_rendition = PlaceholderRenditionMixin.get_rendition
Then you have to set WAGTAIL_PLACEHOLDERIMAGES_DUMMY
to True
and use your desired placeholder source by setting WAGTAIL_PLACEHOLDERIMAGES_SOURCE
. This should be done in your development settings file, so this doesn't get enabled on your servers. E.g.
# settings_dev.py
WAGTAIL_PLACEHOLDERIMAGES_DUMMY = True
WAGTAIL_PLACEHOLDERIMAGES_SOURCE = "//placedog.net/{width}/{height}/"
That should be it!
Project details
Release history Release notifications | RSS feed
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
Hashes for wagtail-placeholder-images-0.1.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | a270fcd6ceaba1e2e4e3d1cab725763d08b31e8baceac746ed23f94554b1171f |
|
MD5 | 332410ab3498b4fae5cc348accba1006 |
|
BLAKE2b-256 | c2f9a55f528c27c0df7d581bb1d0f75255c09620b9daa825a62a0857b6dd05e9 |
Hashes for wagtail_placeholder_images-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7c5da2d70e6df822937b2f01571ed1513a4b86acad5eca21ed1af2190ae28a81 |
|
MD5 | 9e9ea5bf440700afa9ba9981ed029d27 |
|
BLAKE2b-256 | 00713e2f670fe49dbe5602ec356ee65a9eaaec01c3ea708d50042ae1c93104dc |