Skip to content
This repository has been archived by the owner on Oct 21, 2019. It is now read-only.

Latest commit

 

History

History
66 lines (52 loc) · 1.71 KB

filter-admin-post-thumbnail-html.md

File metadata and controls

66 lines (52 loc) · 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' 
					]
				)
			);
		} 
	} 
);