Skip to main content

Adds ability to use placeholder images for local development

Project description

PyPI version

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


Download files

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

Source Distribution

wagtail-placeholder-images-0.1.1.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file wagtail-placeholder-images-0.1.1.tar.gz.

File metadata

  • Download URL: wagtail-placeholder-images-0.1.1.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.0.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

File hashes

Hashes for wagtail-placeholder-images-0.1.1.tar.gz
Algorithm Hash digest
SHA256 4f9070ce3ffaa2be02e0baf6c6b44c9f8d6d9302a60e384f85310c5e6b432bae
MD5 5230a9bd9f59aaa01ae6d05b6d2f713f
BLAKE2b-256 e3258cd14265f3b82fe4ab4ba1f7dcea25b83b82a81055f600aaf0ef82bf3b7e

See more details on using hashes here.

File details

Details for the file wagtail_placeholder_images-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: wagtail_placeholder_images-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 3.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.0.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

File hashes

Hashes for wagtail_placeholder_images-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 44cbdb18e4123c8423758c21f9e25c399c3a1f8349791071786d62e1c6077c0f
MD5 6e7838c7057ce2de886f29a90a00c779
BLAKE2b-256 c12484b73cf258baef5ce6251409516086778cdcb3c7dd4d69d34d39ea6f2e29

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