Support » Plugin: Gutenberg » Youtube embed (WP Classes and Nocookie)

  • I just discovered that it is better to use the youtube-nocookie for enhanced privacy url when embedding a vídeo, because of GDPR. But with Gutenberg it is not working with that urls. I can’t embed them directly.

    I have read here in the forum that the Youtube embed is a youtube functionality that is used by Gutenberg, but at Youtube you have an option when you ask for the code to insert elsewhere, to select the “enhanced privacy”.

    I could get the code to do this, it is like this:

    <iframe width="560" height="315" src="" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>

    It would be great if that could be done directly within wordpress too.

    I also changed a normal youtube embed to html to check what was added and got this:

    <figure class="wp-block-embed-youtube wp-block-embed is-type-video is-provider-youtube wp-has-aspect-ratio"><div class="wp-block-embed__wrapper"> </div></figure>

    And when I get the code to embed from Youtube a video normally is like this:
    <iframe width="560" height="315" src="" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>

    So is not being used the same way. Maybe it changed later. But then, I guess there could be a way to add the “enhanced privacy” option too?

    Also, when I embeded a youtube video normally, it added some classes automatically. One of them was wp-embed-aspect-16-9 and that made a huge white space appear before the video. I am not quite sure that should be added.

Viewing 4 replies - 1 through 4 (of 4 total)
  • I’m no expert on the Gutenberg plugin’s design but my simple workaround for embedding YouTube videos is to use the Custom HTML block.

    • This reply was modified 2 years, 1 month ago by Marion Black.

    Yes, that is what I did as I said. But it would be nice to have the option too. As I saw, the current code is not the same google gives, so, why not have an option to choose wheter you want Enhanced privacy? Easier.

    Also, I don’t like the HTML blocks, because they show the code and not the preview. Before you could edit the HTML and go back to the visual view. Now the HTML blocks stay so. I tried saying “convert to block” again, but then I lost the HTML changes.

    Moderator Marius L. J.



    The embed options in Gutenberg are just fetching what YouTube provide of input, we do not control this at all. If you wish to use the advanced share features (such as the nocookie one), you will have to add it your self, there’s no way around this unless YouTube decides to use that nocookie setting as their default embed option.

    As for previews of the markup, this is possible, in the Custom HTML block, if you view the extra options (by clicking the ellipsis above the block), you should have a preview alternative there.

    It is a shame that it’s not possible to have this option available from here. 🙁

    With the previews I meant it would be nice to see the preview by default instead of code. I am still getting used to Gutenberg and I always have problems choosing the right option, I tend to look for “Code” and end up adding a “Code block” instead of HTML code… Am I maybe the only one? Or could the usability here be improved?

    I think for a basic user that sometimes make “copy and paste” some code found somewhere, it would be nice too if by default the html modified code showed up like it is going to be shown.

    Or maybe that when you convert back the html code again to a block, it keeps the changes? Like added clasess for example.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Youtube embed (WP Classes and Nocookie)’ is closed to new replies.