admin管理员组文章数量:1133652
I was trying to use this to create a Youtube video block using JavaScript:
// Define the YouTube video URL (replace with your desired URL)
const youtubeVideoURL = '';
// Create a new YouTube video block
const youtubeVideoBlock = wp.blocks.createBlock('core-embed', {
url: youtubeVideoURL,
});
But I get the following error:
Uncaught Error: Block type 'core-embed' is not registered.
That this means it's actually impossible to programmatically create an "embed" block for Youtube videos?
It works fine for paragraphs, quotes, images... so I'm surprised this is not working for embeds.
I was trying to use this to create a Youtube video block using JavaScript:
// Define the YouTube video URL (replace with your desired URL)
const youtubeVideoURL = 'https://youtu.be/NNrj0N-yTnM';
// Create a new YouTube video block
const youtubeVideoBlock = wp.blocks.createBlock('core-embed', {
url: youtubeVideoURL,
});
But I get the following error:
Uncaught Error: Block type 'core-embed' is not registered.
That this means it's actually impossible to programmatically create an "embed" block for Youtube videos?
It works fine for paragraphs, quotes, images... so I'm surprised this is not working for embeds.
Share Improve this question asked Oct 5, 2023 at 18:05 AlvaroAlvaro 1411 silver badge12 bronze badges1 Answer
Reset to default 3Perhaps the name you're using is incorrect?
At least in /block-library/src/embed/core-embeds.js the different embed types seem to follow core-embed/{source}
pattern on their names - e.g. core-embed/youtube
. And the embed block itself has core/embed
as its name.
本文标签: javascriptCreate Youtube embed block with createBlock
版权声明:本文标题:javascript - Create Youtube embed block with createBlock 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736783403a1952724.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论