Custom Fields
Re-Envisioned
Support MB Views Youtube link in post.content doesn't render in a MB view

  • Creator
    Topic
  • #27298
    Resolved Henri
    Participant

    Hi Metabox,

    I have a youtube embeded in the post.content. When I don't use a MB view to display the page, it shows the text and the video. However, when I use a MB view and post the content using the following field:
    {{ post.content }}
    it does show the text but doesn't render the video, it only shows the url of the video. Is this a bug? How can I resolve this?

    Kind regards, Henri

Viewing 4 replies - 1 through 4 (of 4 total)
  • Author
    Replies
  • #27306
    Long Nguyen
    Moderator

    Hi,

    It's the normal behavior because the data is saved in the database is the raw value like this

    <!-- wp:embed {"url":"https://www.youtube.com/watch?v=cClgQ9kGfAQ","type":"video","providerNameSlug":"youtube","responsive":true,"className":"wp-embed-aspect-16-9 wp-has-aspect-ratio"} -->
    <figure class="wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
    <code>https://www.youtube.com/watch?v=cClgQ9kGfAQ</code>
    </div></figure>
    <!-- /wp:embed -->

    then Block editor support showing the video on the frontend, but the MB Views only support to show the raw value. You can change to the embed code <iframe> to show the Youtube video via MB Views.

    #27315
    Henri
    Participant

    Hi Long,

    Thanks for you answer. I don't know how I can achieve that. The video is used in the Gutenberg editor as part of the content. So I have text, some images and then the video and then some text again. So when I echo post.content this content all gets displayed, except for the video. If I wrap the post.content in iframe tags only an empty box gets displayed. So how can I target only the video url in existing content with the MB view to wrap that in an iframe tag?

    #27321
    Long Nguyen
    Moderator

    You can use the block Custom HTML and insert the embedded code of Youtube when editing the content. Screenshot https://share.getcloudapp.com/4gu2nAXY

    #27387
    Henri
    Participant

    Using the HTML block makes sense. It does require me to go into each existing post though to change the Youtube link. This is not ideal, but if there is no workaround then I'll have to see how I'm going to fix this.

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.