Enhancing Gutenberg featured image control
I’m wanting to add some functionality to the featured image block in the Gutenberg editor. There are a handful of posts online about how to do this, including a question/answer here (3rd item).
- https://thatdevgirl.com/blog/wordpress-featured-image-and-gutenberg
- https://digitalapps.co/gutenberg-extending-featured-image-component/
- Gutenberg Block – Post Featured Image Filter Hook
Unfortunately, I’m missing something somewhere because I can’t get even the basics to work for me. I’ve got javascript that verifiably loads on the post type edit page as follows:
window.addEventListener("load", function(event){
console.log("featured_image.js loaded and functional...");
});
var el = wp.element.createElement;
function wrapPostFeaturedImage( OriginalComponent ) {
return function( props ) {
return (
el(
wp.element.Fragment,
{},
'Prepend above',
el(
OriginalComponent,
props
),
'Append below'
)
);
}
}
wp.hooks.addFilter(
'editor.PostFeaturedImage',
'dsplugin/wrap-post-featured-image',
wrapPostFeaturedImage
);
But the above is having no effect on the featured image box. I’m new to Gutenberg so I’m probably missing half a dozen things. If someone could point me in the right direction, I’d be grateful.
Leave an answer