How to use the wagtailmedia.blocks.AbstractMediaChooserBlock function in wagtailmedia

To help you get started, we’ve selected a few wagtailmedia examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github praekeltfoundation / molo / molo / core / models.py View on Github external
admin_form_fields = (
        'title',
        'file',
        'collection',
        'duration',
        'width',
        'height',
        'thumbnail',
        'tags',
        'youtube_link',
        'feature_in_homepage',
    )


class MoloMediaBlock(AbstractMediaChooserBlock):
    def render_basic(self, value, context):
        if not value:
            return ''

        if value.type == 'video':
            player_code = '''
            <div>
                <video controls="" height="240" width="320">
                    <source type="video/mp4" src="{0}">
                    Your browser does not support the video tag.
                </video>
            </div>
            '''
        else:
            player_code = '''
            <div></div>
github praekeltfoundation / molo / molo / core / blocks.py View on Github external
def clean(self, value):
        value = super().clean(value)

        # Return an error message if there is html in the value
        has_html = bool(BeautifulSoup(value, "lxml").find())
        if has_html:
            raise ValidationError(
                    _('Please use MarkDown for formatting text instead of '
                      'HTML.')
                )

        return value


class MultimediaBlock(AbstractMediaChooserBlock):
    class Meta:
        icon = 'media'

    def render_basic(self, value, context=None):
        if not value:
            return ''

        if value.type == 'video':
            player_code = '''<div><video controls="" height="240" width="320">
<source type="video/mp4" src="{0}">Click here to download
<a href="{0}">{1}</a></video></div>'''

        else:
            player_code = '''<div><audio controls=""><source type="audio/mpeg" src="{0}">Click here to download
<a href="{0}">{1}</a></audio></div>'''