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.2.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5f62f04c2b78f1b68aa5d1b5335321f1572453520ecc5afee9d4a61a791e89ec |
|
MD5 | 4fc4b2df9198e0bfc6308cc8d86f5579 |
|
BLAKE2b-256 | c54959edb73f74b6203f21a48bb44dcdb4e3d414c74479997065ac27183a73f1 |
Hashes for wagtailimagecaptions-0.2.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 40d5a605f3a417605be30a5bc5118e5f2d748927207de8f41dc897ace5cedf33 |
|
MD5 | 64e7fc7e847ce2e7e7fb63fdc5767179 |
|
BLAKE2b-256 | f07d2d0023fb068c67a187a68fb6acefc74d83dac7b8f1a5096d6b56acc52740 |