Post Thumbnail HTML Filter
July 25, 2018 ยท View on GitHub
Covers the following filters:
admin_post_thumbnail_html
Overview
This filter fires within the Featured Image meta box:
Existing Usage
One existing use is to filter the form output to include additional fields, which are processed on save_post:
Please open a new issue to suggest additional examples of existing usage.
Gutenberg Equivalent
PostFeaturedImage is a React component used to render the Post Featured Image selection tool.
It includes a wp.hooks filter editor.PostFeaturedImage (introduced in Gutenberg v3.3) that enables developers to replace or extend it.
Examples
Replace the contents of the panel:
wp.hooks.addFilter(
'editor.PostFeaturedImage',
'myplugin/myhook',
function() {
return function() {
return wp.element.createElement(
'div',
{},
'The replacement contents or components.'
);
}
}
);
Prepend/Append to the panel contents:
wp.hooks.addFilter(
'editor.PostFeaturedImage',
'myplugin/myhook',
function( original ) {
return function() {
return (
wp.element.createElement(
'div',
{ key: 'outer' + Math.random() },
[
'Prepend above',
_.extend( original( {} ), { key: 'my-key' } ),
'Append below'
]
)
);
}
}
);