A Django app for extending the Wagtail Image model to add captions and alt fields as
Project description
Captions for Wagtail Images
A Django app for extending the Wagtail Image model to add captions and alt fields as well as the extraction of IPTC image meta data.
Installing
Install using pip:
pip install wagtailimagecaptions
Settings
In your settings file, add wagtailimagecaptions
to INSTALLED_APPS
:
INSTALLED_APPS = [
# ...
"wagtailimagecaptions",
# ...
]
You will also need to set a custom Image model in your setting files:
# settings.py
WAGTAILIMAGES_IMAGE_MODEL = "wagtailimagecaptions.CaptionedImage"
Migrating
Heads up! If you have existing images, you will need to create a data migration operation to move the old images into the new model.
How to Use
The custom Image model, CaptionedImage
, adds four new fields to the Wagtail Image model: alt
, caption
, credit
, iptc_data
. When a new image is uploaded via Wagtail's media library, the app will attempt to extract any IPTC meta data found in the file and fill
the alt
, caption
and credit
fields. All IPTC meta data extracted is also stored in iptc_data
.
Example use in a template:
{% load wagtailcore_tags %}
<img src="{{ image.url }}" alt="{{ image.alt }}">{{ image.caption|richtext }}
Adding date paths to image uploads.
To add date paths to the image upload path, you can set WAGTIALIMAGECAPTIONS_UPLOAD_TO_DATE_PATH
in your Django settings file with a valid date format.
# settings.py
WAGTIALIMAGECAPTIONS_UPLOAD_TO_DATE_PATH = "%Y/%m"
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 wagtailimagecaptions-0.1.9.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 86b5966ab5c08347e7732d8477de16f8c358abdd450f756f1af127460f84f7ea |
|
MD5 | 1ed6845ae43fc3ab8ae6c1ec8fa1cceb |
|
BLAKE2b-256 | 74e5498a9a0dc6e6c05682d25aa2850df8d37c662a51a265133df1312bc134fe |
Hashes for wagtailimagecaptions-0.1.9-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8cdefc4f5ce424a82b2bac0cd705b8aa2ee0456761c93797e1776d10e8fdbdd4 |
|
MD5 | 6920815df093809cbb35682ad3c14839 |
|
BLAKE2b-256 | 1da275256acf7d444d9ecbb8a5fcb2039c2f8fe3a54da970df8e3034c93b353a |