Ticket #21195: 21195-get_avatar_url.diff
File 21195-get_avatar_url.diff, 2.8 KB (added by , 12 years ago) |
---|
-
wp-includes/pluggable.php
1569 1569 } 1570 1570 endif; 1571 1571 1572 if ( !function_exists( 'get_avatar ' ) ) :1572 if ( !function_exists( 'get_avatar_url' ) ) : 1573 1573 /** 1574 * Retrieve the avatar for a user who provided a user ID or email address.1574 * Retrieve the avatar URL for a user who provided a user ID or email address. 1575 1575 * 1576 * @since 2.51576 * @since 3.5 1577 1577 * @param int|string|object $id_or_email A user ID, email address, or comment object 1578 1578 * @param int $size Size of the avatar image 1579 1579 * @param string $default URL to a default image to use if no avatar is available 1580 * @param string $alt Alternate text to use in image tag. Defaults to blank1581 1580 * @return string <img> tag for the user's avatar 1582 1581 */ 1583 function get_avatar( $id_or_email, $size = '96', $default = '', $alt = false ) { 1584 if ( ! get_option('show_avatars') ) 1585 return false; 1582 function get_avatar_url( $id_or_email, $size = '96', $default = '' ) { 1586 1583 1587 if ( false === $alt)1588 $safe_alt = '';1589 else1590 $safe_alt = esc_attr( $alt );1591 1592 1584 if ( !is_numeric($size) ) 1593 1585 $size = '96'; 1594 1586 … … 1659 1651 if ( !empty( $rating ) ) 1660 1652 $out .= "&r={$rating}"; 1661 1653 1662 $avatar = "<img alt='{$safe_alt}' src='{$out}' class='avatar avatar-{$size} photo' height='{$size}' width='{$size}' />";1654 $avatar_url = $out; 1663 1655 } else { 1664 $avatar = "<img alt='{$safe_alt}' src='{$default}' class='avatar avatar-{$size} photo avatar-default' height='{$size}' width='{$size}' />";1656 $avatar_url = $default; 1665 1657 } 1666 1658 1659 return apply_filters( 'get_avatar_url', $avatar_url, $id_or_email, $size, $default ); 1660 } 1661 endif; 1662 1663 if ( !function_exists( 'get_avatar' ) ) : 1664 /** 1665 * Retrieve the avatar for a user who provided a user ID or email address. 1666 * 1667 * @since 2.5 1668 * @param int|string|object $id_or_email A user ID, email address, or comment object 1669 * @param int $size Size of the avatar image 1670 * @param string $default URL to a default image to use if no avatar is available 1671 * @param string $alt Alternate text to use in image tag. Defaults to blank 1672 * @return string <img> tag for the user's avatar 1673 */ 1674 function get_avatar( $id_or_email, $size = '96', $default = '', $alt = false ) { 1675 if ( ! get_option('show_avatars') ) 1676 return false; 1677 1678 if ( false === $alt ) 1679 $safe_alt = ''; 1680 else 1681 $safe_alt = esc_attr( $alt ); 1682 1683 if ( !is_numeric($size) ) 1684 $size = '96'; 1685 1686 $avatar_url = get_avatar_url( $id_or_email, $size, $default ); 1687 1688 if ( ! $avatar_url ) 1689 return false; 1690 1691 $avatar = "<img alt='{$safe_alt}' src='{$avatar_url}' class='avatar avatar-{$size} photo' height='{$size}' width='{$size}' />"; 1692 1667 1693 return apply_filters('get_avatar', $avatar, $id_or_email, $size, $default, $alt); 1668 1694 } 1669 1695 endif;