I need help with adding attribute 'caption' of core/image block into saved post content.
Currently saved attributes look like follow:
<!-- wp:image {"id":36,"sizeSlug":"large"} -->
I aim to it looks like this:
<!-- wp:image {"id":36,"sizeSlug":"large","caption":"my caption"} -->
So I tried to use wp filter blocks.getSaveElement:
function test(element, blockType, attributes) {
if (blockType.name !== 'core/image') {
return element;
}
console.log(attributes.caption); // here is my attribute available
return element;
}
wp.hooks.addFilter('blocks.getSaveElement', 'whatever', test);
Unfortunately I still can not figure out, how to save my attribute into post content. Any help please?
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744884093a4599014.html
评论列表(0条)