Skip to content

Conversation

shimotmk
Copy link
Contributor

What?

Similar #70398

Why?

Clicking Reset all doesn't reset the resolution to default.
Fixed it to go back to full resolution like in #70398

How?

Testing Instructions

  1. Open a post or page.
  2. Insert Featured Image block and select a media file.
  3. Change its resolution.
  4. Confirm that it doesn't reset to the first available option.

Testing Instructions for Keyboard

Screenshots or screencast

Before

before.mp4

After

after.mp4

Copy link

Warning: Type of PR label mismatch

To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.

  • Type-related labels to choose from: [Type] Automated Testing, [Type] Breaking Change, [Type] Bug, [Type] Build Tooling, [Type] Code Quality, [Type] Copy, [Type] Developer Documentation, [Type] Enhancement, [Type] Experimental, [Type] Feature, [Type] New API, [Type] Task, [Type] Technical Prototype, [Type] Performance, [Type] Project Management, [Type] Regression, [Type] Security, [Type] WP Core Ticket, Backport from WordPress Core, Gutenberg Plugin.
  • Labels found: .

Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task.

Copy link

github-actions bot commented Jun 24, 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: shimotmk <shimotomoki@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>

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 Jun 25, 2025
Copy link
Contributor

@t-hamano t-hamano left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

I think it's better to use undefined rather than the default media size slug, otherwise the attribute value won't disappear completely when you reset it:

<!-- wp:post-featured-image {"sizeSlug":"full"} /-->

If everything is reset, all attribute values ​​should disappear and return to their initial state, as shown below.

<!-- wp:post-featured-image /-->

@shimotmk
Copy link
Contributor Author

Thank you for your review.

If press the rest button for Resolution only (not Reset all), should sizeSlug be set to undefined ?

If select full in SelectControl, should sizeSlug be set to undefined ?

@shimotmk
Copy link
Contributor Author

Set it to undefined when it matches DEFAULT_MEDIA_SIZE_SLUG.
I thought more consistent with the other attributes.

feature-image-2.mp4

@t-hamano
Copy link
Contributor

<!-- wp:post-featured-image {"sizeSlug":"full"} /-->
<!-- wp:post-featured-image /-->

After some research, I found that these two HTMLs can have different results. See #70526 for more details.

Set it to undefined when it matches DEFAULT_MEDIA_SIZE_SLUG.

In other words, this approach means that users will no longer be able to explicitly select the full media size, and the post-thumbnail media size will be used on the frontend.

This may affect some themes, so we might want to explicitly apply DEFAULT_MEDIA_SIZE_SLUG instead of undefined in the resetAll. So, in my opinion, your first commit is the right approach after all 😄

Let me know what you think!

@shimotmk
Copy link
Contributor Author

shimotmk commented Jun 26, 2025

Thanks for looking into this!

Default and full are different.

I considered setting a sizeSlug default in block.json, but it seems best to avoid that for compatibility reasons.

Appearance also has a default option, so I think it's a good idea to add a default.

default

@shimotmk
Copy link
Contributor Author

Added defaults to options so that they can be reset to their initial values.😄

post-feature-image.mp4

@t-hamano
Copy link
Contributor

@shimotmk Perhaps I was not clear enough. I am not proposing to add a default option in this PR. Whether to add a default option needs to be discussed carefully in #70526.

What I suggest is to simply apply this commit to the trunk.

@shimotmk shimotmk force-pushed the fix/post-featured-image/resetall-mesia-size branch from c36631d to 2d534c3 Compare June 27, 2025 09:22
@shimotmk
Copy link
Contributor Author

Sorry for bothering you.
I reverted to the first commit and merged the latest trunk.

After some research, I found a similar discussion about the UI of the default options for the aspect ratio of the cover block.
#60224 (comment)

Copy link
Contributor

@t-hamano t-hamano left a comment

Choose a reason for hiding this comment

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

LGTM! I think this approach is the best for now.

If a default option is added in the future, we may be able to reconsider the reset behavior.

@t-hamano t-hamano merged commit cf3b3a8 into WordPress:trunk Jun 27, 2025
60 checks passed
@github-actions github-actions bot added this to the Gutenberg 21.2 milestone Jun 27, 2025
@shimotmk shimotmk deleted the fix/post-featured-image/resetall-mesia-size branch June 27, 2025 12:49
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.

2 participants