I am running EE 5.2.6 and have an issue with embedding YouTube videos in a TextArea or TextField. If I do it this way, it does not display the video from the channel entry field.

<div class="video" >

If I add the code directly into the template like this it shows fine:

<div class="video" >
        <iframe width="560" height="315" src="https://www.youtube.com/embed/g0ev7HxaWdg" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>

The TextArea is set to formatting None, but it appears that the field is still stripping out the special characters somehow, thus preventing the video from displaying properly and there is no trace of the iframe in the browser inspection window.

Does anyone know how to resolve this?


Is the value of {video} the entire iframe? if so it's likely because you have double quotes.

Why would you not just have {video} be the YouTube url and do something like this

{if video != ''}
<div class="video" >

This will check to see that there is a {video} value and if so build an iframe with the {video} value as the src.

  • Good suggestion. I tried it and it does not display the content. It actually throws an error saying It refused to display the video in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'. – forrest Aug 23 '19 at 22:18
  • 1
    Hey. Try saving just the video id instead of an embed url and do this: <iframe width="560" height="315" src="http://www.youtube.com/embed/{video_id}?rel=0&controls=2&color=white&autohide=1" frameborder="0" allowfullscreen></iframe>. If that works you can play around with the other parameters. – Shayne Aug 26 '19 at 15:08
  • 1
    Well done Shayne. That worked. Thank you. – forrest Aug 26 '19 at 15:44
  • Great! I'm glad I could help. – Shayne Aug 26 '19 at 16:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.