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

editor.PostFeaturedImage append demo code doesn't allow pre-selected images #20

Open
JSalvo220 opened this issue Mar 1, 2019 · 0 comments

Comments

@JSalvo220
Copy link

I have added our custom plugin to append a string to the Featured Image block (which was originally taken care of using 2 lines of PHP code - just saying).

Here is the JS file:

function addFeaturedImageDescription (original) { 
	return function() { 
		return (
			wp.element.createElement( 
				'div', 
				{ key: 'outer' + Math.random() }, 
				[
					_.extend( original( {} ), { key: 'my-key' } ),
                    'Suggested dimensions: 1104px x 736px'
				]
			)
		);
	}
}

wp.hooks.addFilter( 
	'editor.PostFeaturedImage', 
	'pluginname/addFeaturedImageDescription', 
	addFeaturedImageDescription 
);

When I run that, I get the Featured button and my text - but when I try to edit a post that already has a featured image, it is not pre-selected. If I try to select an image, I get "t is not a function" in edit-post.min.js:12:7166.

Something is amiss from the code provided (as it works fine when I just return original). Can you please provide functional code on how to handle this.

Thanks.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant