1from wagtail.core.rich_text import EmbedHandler 2from wagtail.embeds import format 3from wagtail.embeds.embeds import get_embed 4from wagtail.embeds.models import Embed 5 6 7# Front-end conversion 8 9class MediaEmbedHandler(EmbedHandler): 10 identifier = 'media' 11 12 @staticmethod 13 def get_model(): 14 return Embed 15 16 @staticmethod 17 def get_instance(attrs): 18 return get_embed(attrs['url']) 19 20 @staticmethod 21 def expand_db_attributes(attrs): 22 """ 23 Given a dict of attributes from the <embed> tag, return the real HTML 24 representation for use on the front-end. 25 """ 26 return format.embed_to_frontend_html(attrs['url']) 27