Skip to main content

A wagtail module for creating an image field with annotation metadata

Project description

Combine two fields to create an image with annotation data. Annotations are stored as relative x,y coordinates with custom form data.

Requirements

  • Wagtail > 1.5

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 a Map with id for the annotation being the key.

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):
    text = forms.CharField(widget=forms.TextInput)


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 + [
        AnnotatedImagePanel(
            ImageChooserPanel('image'),
            FieldPanel('annotations'),
            annotation_form=AnnotationForm(), heading='Annotated Image'
        )
    ]

Project details


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