wordpress 提取头像的src
获取用户头像,可以通过
$avatar_html = get_avatar( $email );
获取到头像的html
/** * Retrieve the avatar url for a user who provided a user ID or email address. * * {@see get_avatar()} doesn't return just the URL, so we have to * extract it here. * * @param string $email Email address. * @return string URL for the user's avatar, empty string otherwise. */ function json_get_avatar_url( $avatar_html ) { // Strip the avatar url from the get_avatar img tag. preg_match('/src=["|\'](.+)[\&|"|\']/U', $avatar_html, $matches); if ( isset( $matches[1] ) && ! empty( $matches[1] ) ) { return esc_url_raw( $matches[1] ); } return ''; }

浙公网安备 33010602011771号