Configure Wagtail and Mediaflow
The integration between Mediaflow and Wagtail enables publishing of images and videos stored in Mediaflow directly within Wagtail’s interface. This is ideal for ensuring web editors will always have access to GDPR-compliant files, correctly set alt texts and accessibility-optimised videos.
Settings in Mediaflow
The integration with Wagtail can be used as soon as it is installed. However, to ensure that files are accessible and can be used optimally, administrators must first configure the necessary settings in Mediaflow.
Installing Wagtail’s plugin
To enable the insertion of images and videos from Mediaflow into Wagtail, two separate plugins need to be installed—one for images and one for videos. We recommend installing both, as they are designed to work together. If video insertion is not needed, the option can be hidden via permissions in Wagtail.
The two plugins can be accessed at the following addresses:
Installing Mediaflow’s image plugin
The easiest way to install the plugin is by using the package manager PIP. In your terminal, enter:
pip install mediaflowimage
Edit the website’s settings file
-
Add "mediaflowimage" to the INSTALLED_APPS array.
-
Tell Wagtail to use a custom image form
WAGTAILIMAGES_IMAGE_FORM_BASE = 'mediaflowimage.forms.MediaflowImageForm'
-
Add the API keys required for the plugin (contact Mediaflow support if you have not received them yet).
MEDIAFLOW_CLIENT_ID = <CLIENT ID>
MEDIAFLOW_CLIENT_SECRET = <CLIENT SECRET>
MEDIAFLOW_SERVER_KEY = <REFRESH TOKEN / SERVERKEY>
Custom image models
The image plugin works directly with Wagtail’s standard image model. However, if you want to map Mediaflow image metadata properties to Wagtail images, you must use a custom image model. A custom image model is also required if you wish to log file usage in Mediaflow.
The fields in your image model can be mapped to automatically populate when inserting (uploading) an image from Mediaflow. This is done by defining a mapping in your settings file as follows:
If you need image usage reporting, MEDIAFLOW_META_MAPPING must include a key for the id, mapped to a field in your image model (“mf_mediaflow_id” in the example). Additionally, your image model must have a custom rendering model that adds the attribute data-mf-image-id to all rendered images.
An example of a custom image class that includes a Mediaflow ID field and custom rendering is shown below. The field names in the image model correspond to the field names defined in the MEDIAFLOW_META_MAPPING setting above:
The easiest way to install the plugin is by using the package manager PIP. In your terminal, enter:
pip install mediaflowvideo
Edit the websites settings file
Edit the Settings File ([mysite]/settings/base.py):
1. Add “mediaflowvideo” to the INSTALLED_APPS list (near the beginning of the file).
2. Add “mf-video” to the feature list for the Draftail Rich Text Editor.
-
Add the API keys required for the plugin (contact Mediaflow support if you have not received them yet).
MEDIAFLOW_CLIENT_ID = <CLIENT ID>
MEDIAFLOW_CLIENT_SECRET = <CLIENT SECRET>
MEDIAFLOW_SERVER_KEY = <REFRESH TOKEN / SERVERKEY>