Как показать встроенное видео на главной странице со страницы блога в wagtail?

Как показано на рисунке, я могу вставить видео через URL. но он сохраняет видео как url и текст как все тело. я не могу извлечь только видео и показать на главной странице. https://docs.wagtail.org/en/v4.0.3/editor_manual/new_pages/inserting_videos.html#

я попробовал использовать

from wagtail.core.rich_text import RichText

register = template.Library()

@register.filter(name='extract_videos')
def extract_videos(body):
    videos = []
    # Check if the body content is RichText
    if isinstance(body, RichText):
        # Iterate through each block in the RichText
        for block in body:
            # Check if the block is of type 'embed'
            if block.block_type == 'embed':
                # Append the value (which should be the embedded video URL) to the videos list
                videos.append(block.value)
    return videos
Вернуться на верх