Skip to content

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

@t-hamano

Description

@t-hamano

Description

The Post Author Block can be inserted outside the postId context. For example, you can insert it directly into a single post template. The avatar is displayed correctly, but not in the editor.

On the other hand, the Avatar block correctly shows the avatar placeholder in the editor.

I think the Post Author Block needs a fallback avatar, like the Avatar block:

function useDefaultAvatar() {
const { avatarURL: defaultAvatarUrl } = useSelect( ( select ) => {
const { getSettings } = select( blockEditorStore );
const { __experimentalDiscussionSettings } = getSettings();
return __experimentalDiscussionSettings;
} );
return defaultAvatarUrl;
}

Step-by-step reproduction instructions

  • Paste the following HTML into the Single Posts template:

    <!-- wp:group {"layout":{"type":"constrained"}} -->
    <div class="wp-block-group">
      <!-- wp:heading -->
      <h2 class="wp-block-heading">Avatar Block: Avatar is displayed correctly.</h2>
      <!-- /wp:heading -->
      <!-- wp:avatar /-->
      <!-- wp:heading -->
      <h2 class="wp-block-heading">Author Block: Avatar isn't showing up.</h2>
      <!-- /wp:heading -->
      <!-- wp:post-author /-->
    </div>
    <!-- /wp:group -->
  • Confirm that the avatar placeholder of the Author block isn't displayed in the editor.

Screenshots, screen recording, code snippet

Editor (Single Posts Template)

Image

Front end

Image

Environment info

No response

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

  • Yes

Please confirm which theme type you used for testing.

  • Block
  • Classic
  • Hybrid (e.g. classic with theme.json)
  • Not sure

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Block] Post AuthorAffects the Post Author Block[Type] BugAn existing feature does not function as intended

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions