Skip to content

Conversation

@theaminuli
Copy link
Member

@theaminuli theaminuli commented Sep 19, 2025

What?

  • Added default avatar fallback support to Post Author Block in editor
  • Moved useDefaultAvatar hook to shared utils location for code reusability
  • Fixed avatar placeholder display when Post Author Block is used outside postId context

Why?

  • Post Author Block avatar wasn't showing placeholder in editor when inserted outside postId context (e.g., in single post templates)
  • Avatar Block already had proper fallback mechanism showing placeholder correctly
  • Code duplication existed with useDefaultAvatar logic in Avatar block but not shared

Fixes / Reference
Fixes #71715

How to test:

  1. Open Site Editor and navigate to Single Posts template
  2. Insert the following HTML into the template:
<!-- wp:group {"layout":{"type":"constrained"}} -->
<div class="wp-block-group">
	<!-- wp:post-author {"showAvatar":false} /-->

	<!-- wp:avatar /-->
</div>
<!-- /wp:group -->

  1. Verify that both Avatar and Post Author blocks now show avatar placeholders in the editor
  2. Confirm that Post Author Block avatar setting is enabled and placeholder appears

Files changed:

  • packages/block-library/src/post-author/edit.js - Added useDefaultAvatar import and fallback logic
  • packages/block-library/src/utils/hooks.js - Added shared useDefaultAvatar hook
  • packages/block-library/src/avatar/hooks.js - Refactored to use shared useDefaultAvatar hook

@github-actions
Copy link

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: theaminuli <theaminuldev@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.

@github-actions github-actions bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Sep 19, 2025
@github-actions
Copy link

👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @theaminuli! In case you missed it, we'd love to have you join us in our Slack community.

If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information.

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! This works fine for me.

@t-hamano t-hamano added [Type] Bug An existing feature does not function as intended [Block] Post Author Affects the Post Author Block labels Sep 20, 2025
@t-hamano t-hamano merged commit 238c7e2 into WordPress:trunk Sep 20, 2025
75 checks passed
@github-actions github-actions bot added this to the Gutenberg 21.8 milestone Sep 20, 2025
adamsilverstein pushed a commit to adamsilverstein/gutenberg that referenced this pull request Sep 22, 2025
…side postId context (WordPress#71775)

* Post Author Block: Add useDefaultAvatar fallback to display avatar placeholder outside postId context

* Post Author Block: Update alt text for default avatar to improve accessibility

Co-authored-by: theaminuli <theaminuldev@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Block] Post Author Affects the Post Author Block First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Post Author Block: Avatar isn't showing up outside the postId context

2 participants