YouTube Videos?

So I’m making a blog which will need to be able to handle YouTube videos in the PostPage. However, when I place the iframe or YouTube link, it shows the code/link instead of the video. Is there something I need to do?

This topic has been created from a Discord post (1250172138304962630) to give it more visibility.
It will be on Read-Only mode here.
Join the conversation on Discord

Could you provide more information, what is your render, how are you saving the iframe or youtube embed link.

If this was react, i’d save this as a text string via a simple text input - I’d then render this to an iframe within jsx. This should show as an iframe with the attribute being the embed url

I tried both iframe and embed link in my RichTextBlock. So I’m not sure if it’s possible for it to render through that

You don’t need it to render in the admin panel, totally pointless. But I think there is a plugin for this perhaps?
You want it to render for your end user in the frontend.

Save it as a simple string for the embed URL - output that field to the src attribute of your iframe in JSX or whatever frontend templating language you’re using.

I mean, sure you can just have it rendered on the frontend. But I believe it makes using Strapi pretty rigid. If I wanted to have a RichTextBlock in the body, then with a video, with additional RichText content, it would kinda make the setup redundent code.

As a best practice I’d advise you don’t allow clients to add stuff like iframes to rich text editors.
You can use a dynamic zone for “content” and the components in the dynamic zone could be

“Rich text”
“Image”
“Video”
“BlockQuote”

And in the dynamic zone they can add, richtext then video, then more richtext, then another video, and another video, then more text, maybe an image etc.

It’ll output as an array of components, you can then render it in this order.

This makes it anything other than “pretty rigid”

Yeah. I ended up making it the dynamic zone