Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
master
Switch branches/tags
Go to file
 
 
Cannot retrieve contributors at this time

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' 
					]
				)
			);
		} 
	} 
);