"wp-block-avatar__image {
$border_attributes['class'
]}"
: 'wp-block-avatar__image';
// Unlike class, `get_avatar` doesn't filter the styles via `esc_attr`.
// The style engine does pass the border styles through
// `safecss_filter_attr` however.
$image_styles = !
empty( $border_attributes['style'
] ) ?
sprintf( ' style="%s"',
esc_attr( $border_attributes['style'
] ) ) : '';
if ( !
isset( $block->context
['commentId'
] ) ) { $author_id =
isset( $attributes['userId'
] ) ?
$attributes['userId'
] :
get_post_field( 'post_author',
$block->context
['postId'
] );
$author_name =
get_the_author_meta( 'display_name',
$author_id );
// translators: %s is the Author name.
$alt =
sprintf( __( '%s Avatar'
),
$author_name );
$avatar_block =
get_avatar( $author_id,
$size,
'',
$alt,
array
( 'extra_attr' =>
$image_styles,
'class' =>
$image_classes,
)