Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
67 lines (52 sloc) 1.71 KB

Post Thumbnail HTML Filter

Covers the following filters:

  • admin_post_thumbnail_html

Overview

This filter fires within the Featured Image meta box:

image

Existing Usage

One existing use is to filter the form output to include additional fields, which are processed on save_post:

image

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' 
					]
				)
			);
		} 
	} 
);
You can’t perform that action at this time.