0

I'm using a headless Wordpress linked to a Nuxt projet and I like to modify the output of my Gutenblock when it's called from the REST API.

Current ouput is :

<!-- wp:core-embed/youtube {"url":"https://www.youtube.com/watch?v=6m-Gpb5l5j4","type":"video","providerNameSlug":"youtube","className":"wp-embed-aspect-4-3 wp-has-aspect-ratio"} -->
<figure class="wp-block-embed-youtube wp-block-embed is-type-video is-provider-youtube wp-embed-aspect-4-3 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
https://www.youtube.com/watch?v=6m-Gpb5l5j4
</div></figure>
<!-- /wp:core-embed/youtube -->

Ultimately, I'd like to output the iframe directly in the code as it is currently the case within the PHP template page as :

<figure class="wp-block-embed-youtube wp-block-embed is-type-video is-provider-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe title="Instant Legolas Gen 8: Wisebutt Comebacks!" width="500" height="281" src="https://www.youtube.com/embed/k6zznk0BDd4?feature=oembed" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</div></figure>

Is there a simple say to achieve this? Any hooks? Thanks

  • Wordpress uses something called oEmbed which resolves the youtube URL into correct iframe code. To achieve this, you would have to implement the same in your JS components, potentially via a 3rd party library. I'm not sure if it's easily possible to save the rendered oEmbed markup. – Fabian Marz Nov 27 '19 at 13:15

Your Answer

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

Browse other questions tagged or ask your own question.