Support Forum
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
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.
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?
You can use the block Custom HTML and insert the embedded code of Youtube when editing the content. Screenshot https://share.getcloudapp.com/4gu2nAXY
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.
Hi there,
I've been troubleshooting YouTube embeds for much of the afternoon, and I finally narrowed it down to MB Views and found this post.
I don't know exactly how WP handles these embeds on the frontend, but is there a way to load or replicate the necessary script through Views, either as an HTML script tag or in the JS panel?
I know my content editors are going to be using this embed functionality regularly, so I would love to find a way to give them a simple embed block rather than using an HTML block.
Should I expect that this issue will be true with the rest of the embed blocks?