Thread tagged as: Question, Problem, Blog

Embed youtube video in blog post

I need a blog post editor to be able to e,bed youtube videos anywhere within the post. Currently I have this in my post.html template:

<perch:if exists="video">
        <div class="embed-container">
            <iframe width="480" height="270" src="<perch:blog id="video" type="text" label="YouTube URL" required="false" title="false" help="copy and paste full link to YouTube video" />&rel=0" frameborder="0" allowfullscreen></iframe>

2 Problems...

1) This forces the video to appear in a specific place in the layout. I need the editor to have freedom to place the embed wherever they like.

2) The iframe appears in the page source, but the video isn't showing. Just an empty space.

Chris James

Chris James 0 points

  • 5 years ago
Rachel Andrew

Rachel Andrew 394 points
Perch Support

If you use Blocks you can make this video into a block along with regular content and anything else, this is how you allow them to place things where they want.

I'm also not sure why you are not using the YouTube Field Type which is designed for this job.

Matt Bee

Matt Bee 0 points
Registered Developer

With regards the video not playing, AFAIK you have to change the URL structure to allow a video play in an iframe - so take the ID from the YouTube URL (i.e. BN0JlMZCtNU in this url: and change it to be included in the embed URL, i.e. //

And as Rachel suggests, Block will let you move the video around to appear in a different order.