Skip to content

Featured Image: Fix available options in resolution selector according to theme support #70632

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

Open
wants to merge 5 commits into
base: trunk
Choose a base branch
from

Conversation

yashjawale
Copy link
Contributor

What?

Closes #70526

This PR changes the default select dropdown value of featured image size to be post-thumbnail instead of full to reflect the default behavior on frontend

Why?

By default, when we add featured image block it doesn't include thesizeSlug attribute in the generated markup
Hence, the block uses the fallback value of post-thumbnail in the frontend

$size_slug = isset( $attributes['sizeSlug'] ) ? $attributes['sizeSlug'] : 'post-thumbnail';

However, the select dropdown in the editor shows Full as the default size, there is a difference in rendered image in frontend with the default value vs explicitly selected Full size as shown in #70526

This PR just changes the initially displayed dropdown value when adding featured image & doesn't affect the size used in frontend

How?

This PR modifies the value of DEFAULT_MEDIA_SIZE_SLUG constant to be post-thumbnail according to default behavior instead of full used before

const DEFAULT_MEDIA_SIZE_SLUG = 'full';

Testing Instructions

  1. Open a post.
  2. Insert a featured image block
  3. Observe the Resolution value under block settings
Before After
image image

@yashjawale yashjawale marked this pull request as ready for review July 11, 2025 06:26
Copy link

github-actions bot commented Jul 11, 2025

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: yashjawale <[email protected]>
Co-authored-by: mukeshpanchal27 <[email protected]>
Co-authored-by: Mamaduka <[email protected]>
Co-authored-by: t-hamano <[email protected]>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@t-hamano t-hamano added [Type] Bug An existing feature does not function as intended [Block] Post Featured Image Affects the Post Featured Image Block labels Jul 11, 2025
@@ -46,7 +46,7 @@ import { unlock } from '../lock-unlock';

const ALLOWED_MEDIA_TYPES = [ 'image' ];
const { ResolutionTool } = unlock( blockEditorPrivateApis );
const DEFAULT_MEDIA_SIZE_SLUG = 'full';
const DEFAULT_MEDIA_SIZE_SLUG = 'post-thumbnail';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead post-thumbnail we should update default value in server-side

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From my understanding, post-thumbnail was set to be default in the block's render.php as it was the default behavior before the option to choose resolution was added
Ref: #38044 (comment)

So won't it be better to leave the fallback behavior as it is & instead change the displayed value in editor to reflect actual behavior...?

@yashjawale yashjawale changed the title Featured Image: Set default resolution dropdown value to post-thumbnail [WIP] Featured Image: Fix available options in resolution selector Jul 24, 2025
@yashjawale
Copy link
Contributor Author

Updated the implementation according to #70526 (comment)

Only difference from the comment being using empty strings instead of undefined as value of options & then accordingly setting the attribute to undefined

This was done because SelectControl uses the label as value when value is undefined, to tackle this empty strings were used as option values

When theme supports post-thumbnail size: [eg. twentytwentyone]

image

When theme doesn't support post-thumbnail size: [eg. blank theme with just file headers]

image

The highlighted ones are the default options, having value as undefined

@yashjawale yashjawale changed the title [WIP] Featured Image: Fix available options in resolution selector Featured Image: Fix available options in resolution selector according to theme support Jul 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Post Featured Image Affects the Post Featured Image Block [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Featured Image: "post-thumbnail" media size may be needed
3 participants