Metadata-Version: 2.1
Name: wagtailimagecaptions
Version: 0.2.5
Summary: A Django app for extending the Wagtail Image model to add captions and alt fields as
Author-email: Stephan Rohde <appsupport@newshour.org>
Description-Content-Type: text/markdown
Classifier: License :: OSI Approved :: BSD License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Framework :: Wagtail
Classifier: Framework :: Wagtail :: 4
Classifier: Framework :: Wagtail :: 5
Classifier: Framework :: Wagtail :: 6
Requires-Dist: Django >= 4.1
Requires-Dist: wagtail >= 5.0
Requires-Dist: pillow >= 9.5.0
Project-URL: Home, https://github.com/newshour/wagtailimagecaptions/

# 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.

![screenshot](https://github.com/newshour/wagtailimagecaptions/assets/14984514/278f5d01-7f2e-48a8-98fd-aaaa6c2d6b8c)

## Installing

Install using pip:

```sh
pip install wagtailimagecaptions
```

### Settings

In your settings file, add `wagtailimagecaptions` to `INSTALLED_APPS`:

```python
INSTALLED_APPS = [
    # ...
    "wagtailimagecaptions",
    # ...
]
```

You will also need to set a custom Image model in your setting files:

```python
# settings.py
WAGTAILIMAGES_IMAGE_MODEL = "wagtailimagecaptions.CaptionedImage"
```

### Migrating

Heads up! If you have existing images, you will need to create a [data migration operation](https://docs.wagtail.org/en/latest/advanced_topics/images/custom_image_model.html#migrating-from-the-builtin-image-model) 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:

```python
{% 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.

```python
# settings.py
WAGTIALIMAGECAPTIONS_UPLOAD_TO_DATE_PATH = "%Y/%m"
```
