Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only display Featured Image field if theme supports post thumbnails #2523

Closed
aduth opened this issue Aug 24, 2017 · 7 comments
Closed

Only display Featured Image field if theme supports post thumbnails #2523

aduth opened this issue Aug 24, 2017 · 7 comments
Assignees
Labels
Core REST API Task Task for Core REST API efforts

Comments

@aduth
Copy link
Member

aduth commented Aug 24, 2017

A Featured Image field should only be available both if the current post type has thumbnail supports (available from post types endpoints) and the theme supports post thumbnails. It is not currently possible to retrieve theme supports from the REST API. Alternatives exist, notably bootstrapping this data server-side on page load, but see #2499 for context on why this is not advisable.

@jeffpaul
Copy link
Member

This ticket was mentioned in Slack in #core-editor by jeffpaul. View the logs.

@jeffpaul jeffpaul added this to the Merge Proposal milestone Feb 22, 2018
@mtias mtias modified the milestones: Merge Proposal, WordPress 5.0, Core API Mar 7, 2018
@danielbachhuber
Copy link
Member

After #6318 lands, we'll be able to use the theme_supports attribute on the index to expose this data into Gutenberg.

@danielbachhuber danielbachhuber self-assigned this Apr 23, 2018
@danielbachhuber
Copy link
Member

@aduth @youknowriad @gziolo I'm not quite sure the check itself lives within PostFeaturedImageCheck or PostTypeSupportCheck. Do any of you have an opinion?

And, on that note, it's odd that PostTypeSupportCheck accepts an array of supportKeys. I can't think of a use case for how PostTypeSupportCheck would process multiple values. Currently, it's only ever used in its singular form:

$ ack '<PostTypeSupportCheck'
post-author/check.js
26:	return <PostTypeSupportCheck supportKeys="author">{ children }</PostTypeSupportCheck>;
post-excerpt/check.js
7:	return <PostTypeSupportCheck { ...props } supportKeys="excerpt" />;
post-last-revision/check.js
16:	return <PostTypeSupportCheck supportKeys="revisions" >{ children }</PostTypeSupportCheck>;

@danielbachhuber danielbachhuber changed the title REST API: Theme supports (featured image) Only display Featured Image field if theme supports post thumbnails Apr 25, 2018
@gziolo
Copy link
Member

gziolo commented Apr 26, 2018

There is one use case where two values are necessary for PostTypeSupportCheck to render its content:

<PostTypeSupportCheck supportKeys={ [ 'comments', 'trackbacks' ] }>

PostFeaturedImageCheck only wraps PostTypeSupportCheck which provides the supportKeys value and handles the logic of conditional rendering of all children elements passed down.

@aduth
Copy link
Member Author

aduth commented Apr 30, 2018

Related: #4815, #4812

@aduth
Copy link
Member Author

aduth commented Apr 30, 2018

I can't think of a use case for how PostTypeSupportCheck would process multiple values.

Previously: #4161 (review)

@aduth
Copy link
Member Author

aduth commented Apr 30, 2018

Might we want a new/separate ThemeSupportCheck ? Then use a combination of ThemeSupportCheck and PostTypeSupportCheck in PostFeaturedImageCheck ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Core REST API Task Task for Core REST API efforts
Projects
None yet
Development

No branches or pull requests

6 participants