Posts: Provide a HiDPI version for the avatar used in post locked dialogs.

Props wpdesk, audrasjb, ocean90.
Fixes #39633.

git-svn-id: https://develop.svn.wordpress.org/trunk@48318 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Dominik Schilling 2020-07-05 12:58:20 +00:00
parent 42d51e4e2e
commit d65c0a770c
3 changed files with 22 additions and 10 deletions

View File

@ -529,7 +529,14 @@ $( document ).on( 'heartbeat-tick.wp-check-locked-posts', function( e, data ) {
row.find('.check-column checkbox').prop('checked', false);
if ( lock_data.avatar_src ) {
avatar = $( '<img class="avatar avatar-18 photo" width="18" height="18" alt="" />' ).attr( 'src', lock_data.avatar_src.replace( /&amp;/g, '&' ) );
avatar = $( '<img />', {
'class': 'avatar avatar-18 photo',
width: 18,
height: 18,
alt: '',
src: lock_data.avatar_src,
srcset: lock_data.avatar_src_2x ? lock_data.avatar_src_2x + ' 2x' : undefined
} );
row.find('.column-title .locked-avatar').empty().append( avatar );
}
row.addClass('wp-locked');

View File

@ -200,7 +200,14 @@ window.wp = window.wp || {};
}
if ( received.lock_error.avatar_src ) {
avatar = $( '<img class="avatar avatar-64 photo" width="64" height="64" alt="" />' ).attr( 'src', received.lock_error.avatar_src.replace( /&amp;/g, '&' ) );
avatar = $( '<img />', {
'class': 'avatar avatar-64 photo',
width: 64,
height: 64,
alt: '',
src: received.lock_error.avatar_src,
srcset: received.lock_error.avatar_src_2x ? received.lock_error.avatar_src_2x + ' 2x' : undefined
} );
wrap.find('div.post-locked-avatar').empty().append( avatar );
}

View File

@ -1053,9 +1053,9 @@ function wp_check_locked_posts( $response, $data, $screen_id ) {
'text' => sprintf( __( '%s is currently editing' ), $user->display_name ),
);
$avatar = get_avatar( $user->ID, 18 );
if ( $avatar && preg_match( "|src='([^']+)'|", $avatar, $matches ) ) {
$send['avatar_src'] = $matches[1];
if ( get_option( 'show_avatars' ) ) {
$send['avatar_src'] = get_avatar_url( $user->ID, array( 'size' => 18 ) );
$send['avatar_src_2x'] = get_avatar_url( $user->ID, array( 'size' => 36 ) );
}
$checked[ $key ] = $send;
@ -1103,11 +1103,9 @@ function wp_refresh_post_lock( $response, $data, $screen_id ) {
'text' => sprintf( __( '%s has taken over and is currently editing.' ), $user->display_name ),
);
$avatar = get_avatar( $user->ID, 64 );
if ( $avatar ) {
if ( preg_match( "|src='([^']+)'|", $avatar, $matches ) ) {
$error['avatar_src'] = $matches[1];
}
if ( get_option( 'show_avatars' ) ) {
$error['avatar_src'] = get_avatar_url( $user->ID, array( 'size' => 64 ) );
$error['avatar_src_2x'] = get_avatar_url( $user->ID, array( 'size' => 128 ) );
}
$send['lock_error'] = $error;