wagtailvideos
=============
.. image:: https://gitlab.com/neonjungle/wagtailvideos/badges/master/pipeline.svg
:target: https://gitlab.com/neonjungle/wagtailvideos/pipelines?ref=master
Based on wagtailimages. The aim was to have feature parity with images
but for html5 videos. Includes the ability to transcode videos to a
html5 compliant codec using ffmpeg.
Requirements
------------
- Wagtail >= 4.0 (for older wagtail version see the tags)
- `ffmpeg `__
Installing
----------
Install using pypi
.. code:: bash
pip install wagtailvideos
Add `wagtailvideos` to your installed apps.
.. code:: python
INSTALLED_APPS = [
'wagtailvideos',
]
Using
-----
On a page model:
~~~~~~~~~~~~~~~~
Implement as a ``ForeignKey`` relation, same as wagtailimages.
.. code:: python
from django.db import models
from wagtail.admin.edit_handlers import FieldPanel
from wagtail.core.fields import RichTextField
from wagtail.core.models import Page
from wagtailvideos.edit_handlers import VideoChooserPanel
class HomePage(Page):
body = RichtextField()
header_video = models.ForeignKey('wagtailvideos.Video',
related_name='+',
null=True,
on_delete=models.SET_NULL)
content_panels = Page.content_panels + [
FieldPanel('body'),
VideoChooserPanel('header_video'),
]
In a Streamfield:
~~~~~~~~~~~~~~~~~
A VideoChooserBlock is included
.. code:: python
from wagtail.admin.edit_handlers import StreamFieldPanel
from wagtail.core.fields import StreamField
from wagtail.core.models import Page
from wagtailvideos.blocks import VideoChooserBlock
class ContentPage(Page):
body = StreamField([
('video', VideoChooserBlock()),
])
content_panels = Page.content_panels + [
StreamFieldPanel('body'),
]
In template:
~~~~~~~~~~~~
The video template tag takes one required postitional argument, a video
field. All extra attributes are added to the surrounding ``