Allows users to combine a Wagtail images with custom annotation data. Annotations are entered in the admin by clicking points on an image, annotation data is then stored with relative x,y coordinates and optional extra form data.
Requirements
Wagtail >= 2.7
Django >= 2.0
Installing
Install using pypi
pip install wagtailannotatedimage
Using
Extend the BaseAnnotationForm to define what data should be stored with annotations. AnnotationsField stores the annotations data as json, converting to a dict on retrieval.
from django import forms
from django.db import models
from wagtail.wagtailcore.models import Page
from wagtailannotatedimage.edit_handlers import AnnotatedImagePanel
from wagtailannotatedimage.fields import AnnotationsField
from wagtailannotatedimage.forms import BaseAnnotationForm
class AnnotationForm(BaseAnnotationForm):
title = forms.CharField()
about = forms.TextField()
class TestPage(Page):
image = models.ForeignKey('wagtailimages.Image', blank=True, null=True,
on_delete=models.SET_NULL, related_name="+")
annotations = AnnotationsField(blank=True)
content_panels = Page.content_panels + [
# First parameter - name of the image field
# Second parameter - name of the annotation field
# annotation_form - optional, the form used for annotations if you need to store data for each point
AnnotatedImagePanel(
'image', 'annotations',
annotation_form=AnnotationForm(), heading='Annotated Image'
)
]
<div class='image-container'>
{% image page.image('width-500') %}
{% for annotation in page.annotations %}
<div
class='annotation'
style="left: {{ annotation.x * 100 }}%; top: {{ annotation.y * 100 }}%;"
>
<h3>{{ annotation.fields.title }}</h3>
<p>{{ annotation.fields.about }}</p>
</div>
{% endfor %}
</div>
.image-container {
position: relative;
}
.image-container > img {
width: 100%;
height: auto;
}
.annotation {
position: absolute;
}
Release files for wagtailannotatedimage 2.7.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| wagtailannotatedimage-2.7.0.tar.gz | 10.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| wagtailannotatedimage-2.7.0-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details |
Total release size: 26.8 kB
Release files / wagtailannotatedimage-2.7.0.tar.gz
| Download URL | wagtailannotatedimage-2.7.0.tar.gz |
|---|---|
| Size | 10.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
55f8d49e06456a8f8b8be19647a7c26c680558b9c5195f0ff471cf1614eaaa9d
|
|
BLAKE2b-256 checksum How to use checksums |
9a69e932760e5501bd202270fc3d101722f2f8ccc94c356fc6b9e135e919506a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/33.1.1 requests-toolbelt/0.9.1 tqdm/4.40.2 CPython/3.5.3
|
Release files / wagtailannotatedimage-2.7.0-py2.py3-none-any.whl
| Download URL | wagtailannotatedimage-2.7.0-py2.py3-none-any.whl |
|---|---|
| Size | 16.0 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
3c3e98406dc0f1c4a48cb26ddf7528c6ff51bd1b991dcf7a1dd8a648b8d7bd28
|
|
BLAKE2b-256 checksum How to use checksums |
51b690da9111e0eeaa94ab0713cbc5eb3b9ac5b625b487d673d108c2c83b1443
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/33.1.1 requests-toolbelt/0.9.1 tqdm/4.40.2 CPython/3.5.3
|