Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_filter( 'get_avatar', 'override_user_avatar', 11, 6 );
- function override_user_avatar( $avatar, $user_id, $size, $default, $alt, $args ) {
- if ( 500 === $size ) {
- $profile_picture = get_the_author_meta( 'profile_picture', $user_id );
- if ( $profile_picture ) {
- $image = wp_get_attachment_image_src( $profile_picture, 'full' );
- $class = array( 'avatar', 'avatar-' . (int) $args['size'], 'photo' );
- if ( ! $args['found_avatar'] || $args['force_default'] ) {
- $class[] = 'avatar-default';
- }
- if ( $args['class'] ) {
- if ( is_array( $args['class'] ) ) {
- $class = array_merge( $class, $args['class'] );
- } else {
- $class[] = $args['class'];
- }
- }
- $avatar = sprintf(
- "<img alt='%s' src='%s' srcset='%s' class='%s' height='%d' width='%d' %s/>",
- esc_attr( $args['alt'] ),
- esc_url( $image[0] ),
- esc_attr( "$image[0] 2x" ),
- esc_attr( join( ' ', $class ) ),
- (int) $args['height'],
- (int) $args['width'],
- $args['extra_attr']
- );
- }
- }
- return $avatar;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement