当前位置: 首页>>代码示例>>PHP>>正文


PHP XenForo_Template_Helper_Core::helperAvatarUrl方法代码示例

本文整理汇总了PHP中XenForo_Template_Helper_Core::helperAvatarUrl方法的典型用法代码示例。如果您正苦于以下问题:PHP XenForo_Template_Helper_Core::helperAvatarUrl方法的具体用法?PHP XenForo_Template_Helper_Core::helperAvatarUrl怎么用?PHP XenForo_Template_Helper_Core::helperAvatarUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在XenForo_Template_Helper_Core的用法示例。


在下文中一共展示了XenForo_Template_Helper_Core::helperAvatarUrl方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: get_avatar


//.........这里部分代码省略.........
         }
     } elseif (is_object($id_or_email)) {
         // No avatar for pingbacks or trackbacks
         /**
          * Filter the list of allowed comment types for retrieving avatars.
          *
          * @since 3.0.0
          *
          * @param array $types An array of content types. Default only contains 'comment'.
          */
         $allowed_comment_types = apply_filters('get_avatar_comment_types', array('comment'));
         if (!empty($id_or_email->comment_type) && !in_array($id_or_email->comment_type, (array) $allowed_comment_types)) {
             return false;
         }
         if (!empty($id_or_email->user_id)) {
             $id = (int) $id_or_email->user_id;
             $user = get_userdata($id);
             if ($user) {
                 $email = $user->user_email;
             }
         }
         if (!$email && !empty($id_or_email->comment_author_email)) {
             $email = $id_or_email->comment_author_email;
         }
     } else {
         $email = $id_or_email;
     }
     if (id == -1 | email == '' || is_admin()) {
         if (empty($default)) {
             $avatar_default = get_option('avatar_default');
             if (empty($avatar_default)) {
                 $default = 'mystery';
             } else {
                 $default = $avatar_default;
             }
         }
         if (!empty($email)) {
             $email_hash = md5(strtolower(trim($email)));
         }
         if (is_ssl()) {
             $host = 'https://secure.gravatar.com';
         } else {
             if (!empty($email)) {
                 $host = sprintf("http://%d.gravatar.com", hexdec($email_hash[0]) % 2);
             } else {
                 $host = 'http://0.gravatar.com';
             }
         }
         if ('mystery' == $default) {
             $default = "{$host}/avatar/ad516503a11cd5ca435acc9bb6523536?s={$size}";
         } elseif ('blank' == $default) {
             $default = $email ? 'blank' : includes_url('images/blank.gif');
         } elseif (!empty($email) && 'gravatar_default' == $default) {
             $default = '';
         } elseif ('gravatar_default' == $default) {
             $default = "{$host}/avatar/?s={$size}";
         } elseif (empty($email)) {
             $default = "{$host}/avatar/?d={$default}&s={$size}";
         } elseif (strpos($default, 'http://') === 0) {
             $default = add_query_arg('s', $size, $default);
         }
         if (!empty($email)) {
             $out = "{$host}/avatar/";
             $out .= $email_hash;
             $out .= '?s=' . $size;
             $out .= '&d=' . urlencode($default);
             $rating = get_option('avatar_rating');
             if (!empty($rating)) {
                 $out .= "&r={$rating}";
             }
             $out = str_replace('&', '&', esc_url($out));
             $avatar = "<img alt='{$safe_alt}' src='{$out}' class='avatar avatar-{$size} photo' height='{$size}' width='{$size}' />";
         } else {
             $avatar = "<img alt='{$safe_alt}' src='{$default}' class='avatar avatar-{$size} photo avatar-default' height='{$size}' width='{$size}' />";
         }
         /**
          * Filter the avatar to retrieve.
          *
          * @since 2.5.0
          *
          * @param string            $avatar      Image tag for the user's avatar.
          * @param int|object|string $id_or_email A user ID, email address, or comment object.
          * @param int               $size        Square avatar width and height in pixels to retrieve.
          * @param string            $alt         Alternative text to use in the avatar image tag.
          *                                       Default empty.
          */
         return apply_filters('get_avatar', $avatar, $id_or_email, $size, $default, $alt);
     } else {
         //get user's name from wordpress database
         $username = get_userdata($id);
         $username = $username->user_login;
         //get user's information, from xenforo, by user's name
         global $xf;
         $user = $xf->getUserByName($username);
         $avatar_url = XenForo_Template_Helper_Core::helperAvatarUrl($user, 's', null, true);
         //home stretch!
         $avatar_url = "<img alt='" . $id . "' src='" . $avatar_url . "' class='avatar avatar-" . $size . " photo avatar-default' height='" . $size . "' width='" . $size . "' />";
         return $avatar_url;
     }
 }
开发者ID:Troposphir,项目名称:troposphir,代码行数:101,代码来源:xenforo_avatars.php


注:本文中的XenForo_Template_Helper_Core::helperAvatarUrl方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。