user_id; } elseif ( ( function_exists( 'is_email' ) && is_email( $id_or_email ) ) || ( !function_exists( 'is_email' ) && !is_numeric( $id_or_email ) ) ) { $id = get_user_by_email( $id_or_email, array( 'by' => 'email' ) )->ID; } else { $id = (int)$id_or_email; } if ( !$id ) return $avatar; $id = md5( $id ); $location = 'avatars/' . substr( $id, 0, 1 ) . '/' . substr( $id, 0, 2 ) . '/' . substr( $id, 0, 3 ) . '/' . $id . '.png'; if ( !file_exists( trailingslashit( BAVATARS_BBPRESS_PATH ) . $location ) ) return $avatar; if ( $size != 512 ) { $_location = $location; $location = 'avatars/' . substr( $id, 0, 1 ) . '/' . substr( $id, 0, 2 ) . '/' . substr( $id, 0, 3 ) . '/' . $id . '_' . $size . '.png'; } if ( !file_exists( trailingslashit( BAVATARS_BBPRESS_PATH ) . $location ) ) { $src = imagecreatefrompng( trailingslashit( BAVATARS_BBPRESS_PATH ) . $_location ); imagesavealpha( $src, true ); imagealphablending( $src, false ); $temp = imagecreatetruecolor( $size, $size ); imagesavealpha( $temp, true ); imagealphablending( $temp, false ); imagecopyresampled( $temp, $src, 0, 0, 0, 0, $size, $size, 512, 512 ); imagepng( $temp, trailingslashit( BAVATARS_BBPRESS_PATH ) . $location, 9 ); imagedestroy( $temp ); imagedestroy( $src ); } return '' . $alt . ''; } add_filter( 'get_avatar', 'bavatars_filter', 10, 5 );