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

Post Author: Avoid errors when the user avatars are disabled #45989

Merged
merged 1 commit into from
Nov 23, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/block-library/src/post-author/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function PostAuthorEdit( {
attributes;
const avatarSizes = [];
const authorName = authorDetails?.name || __( 'Post Author' );
if ( authorDetails ) {
if ( authorDetails?.avatar_urls ) {
Object.keys( authorDetails.avatar_urls ).forEach( ( size ) => {
Comment on lines +65 to 66
Copy link
Member Author

Choose a reason for hiding this comment

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

This is a regression after #43807.

avatarSizes.push( {
value: size,
Expand Down Expand Up @@ -172,7 +172,7 @@ function PostAuthorEdit( {
</BlockControls>

<div { ...blockProps }>
{ showAvatar && authorDetails && (
{ showAvatar && authorDetails?.avatar_urls && (
Copy link
Member Author

Choose a reason for hiding this comment

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

I noticed this after fixing the initial regression.

<div className="wp-block-post-author__avatar">
<img
width={ attributes.avatarSize }
Expand Down