Skip to:
Content

BuddyPress.org

Changeset 7404


Ignore:
Timestamp:
10/09/2013 06:31:59 PM (11 years ago)
Author:
boonebgorges
Message:

Improve inline docs for bp_core_fetch_avatar()

See #5022

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-core/bp-core-avatars.php

    r7228 r7404  
    9393
    9494/**
    95  * bp_core_fetch_avatar()
    96  *
    97  * Fetches an avatar from a BuddyPress object. Supports user/group/blog as
    98  * default, but can be extended to include your own custom components too.
    99  *
    100  * @global $current_blog WordPress global containing information and settings for the current blog being viewed.
    101  * @param array $args Determine the output of this function
     95 * Get an avatar for a BuddyPress object.
     96 *
     97 * Supports avatars for users, groups, and blogs by default, but can be
     98 * extended to support custom components as well.
     99 *
     100 * This function gives precedence to locally-uploaded avatars. When a local
     101 * avatar is not found, Gravatar is queried. To disable Gravatar fallbacks
     102 * locally:
     103 *    add_filter( 'bp_core_fetch_avatar_no_grav', '__return_true' );
     104 *
     105 * @param array $args {
     106 *     An array of arguments. All arguments are technically optional; some
     107 *     will, if not provided, be auto-detected by bp_core_fetch_avatar(). This
     108 *     auto-detection is described more below, when discussing specific
     109 *     arguments.
     110 *
     111 *     @type int|bool $item_id The numeric ID of the item for which you're
     112 *                             requesting an avatar (eg, a user ID). If no
     113 *                             'item_id' is present, the function attempts to
     114 *                             infer an ID from the 'object' + the current
     115 *                             context: if 'object' is 'user' and the current
     116 *                             page is a user page, 'item_id' will default to
     117 *                             the displayed user ID; if 'group' and on a group
     118 *                             page, to the current group ID; if 'blog', to the
     119 *                             current blog's ID. If no 'item_id' can be
     120 *                             determined in this way, the function returns
     121 *                             false. Default: false.
     122 *     @type string $object The kind of object for which you're getting an
     123 *                          avatar. BuddyPress natively supports three options:
     124 *                          'user', 'group', 'blog'; a plugin may register more.
     125 *                          Default: 'user'.
     126 *     @type string $type When a new avatar is uploaded to BP, 'thumb' and
     127 *                        'full' versions are saved. This parameter specifies
     128 *                        whether you'd like the 'full' or smaller 'thumb'
     129 *                        avatar. Default: 'thumb'.
     130 *     @type string|bool $avatar_dir The name of the subdirectory where the
     131 *                                   requested avatar should be found. If no
     132 *                                   value is passed, 'avatar_dir' is inferred
     133 *                                   from 'object': 'user' becomes 'avatars',
     134 *                                   'group' becomes 'group-avatars', 'blog'
     135 *                                   becomes 'blog-avatars'. Remember that this
     136 *                                   string denotes a subdirectory of BP's
     137 *                                   main avatar directory (usually based on
     138 *                                   {@link wp_upload_dir()}); it's a string
     139 *                                   like 'group-avatars' rather than the full
     140 *                                   directory path. Generally, it'll only be
     141 *                                   necessary to override the default value if
     142 *                                   storing avatars in a non-default location.
     143 *                                   Defaults to false (auto-detected).
     144 *     @type int|bool $width Requested avatar width. The unit is px. This value
     145 *                           is used to build the 'width' attribute for the
     146 *                           <img> element. If no value is passed, BP uses the
     147 *                           global avatar width for this avatar type. Default:
     148 *                           false (auto-detected).
     149 *     @type int|bool $height Requested avatar height. The unit is px. This value
     150 *                           is used to build the 'height' attribute for the
     151 *                           <img> element. If no value is passed, BP uses the
     152 *                           global avatar height for this avatar type. Default:
     153 *                           false (auto-detected).
     154 *     @type string $class The CSS class for the <img> element. Note that BP
     155 *                         uses the 'avatar' class fairly extensively in its
     156 *                         default styling, so if you plan to pass a custom
     157 *                         value, consider appending it to 'avatar' (eg
     158 *                         'avatar foo') rather than replacing it altogether.
     159 *                         Default: 'avatar'.
     160 *     @type string|bool $css_id The CSS id for the <img> element.
     161 *                               Default: false.
     162 *     @type string $title The title attribute for the <img> element.
     163 *                         Default: false.
     164 *     @type string $alt The alt attribute for the <img> element. In BP, this
     165 *                       value is generally passed by the wrapper functions,
     166 *                       where the data necessary for concatenating the string
     167 *                       is at hand; see {@link bp_get_activity_avatar()} for an
     168 *                       example. Default: ''.
     169 *     @type string|bool $email An email to use in Gravatar queries. Unless
     170 *                              otherwise configured, BP uses Gravatar as a
     171 *                              fallback for avatars that are not provided
     172 *                              locally. Gravatar's API requires using a hash of
     173 *                              the user's email address; this argument
     174 *                              provides it. If not provided, the function
     175 *                              will infer it: for users, by getting the user's
     176 *                              email from the database, for groups/blogs, by
     177 *                              concatenating "{$item_id}-{$object}@{bp_get_root_domain()}".
     178 *                              The user query adds overhead, so it's
     179 *                              recommended that wrapper functions provide a
     180 *                              value for 'email' when querying user IDs.
     181 *                              Default: false.
     182 *     @type bool $no_grav Whether to disable the default Gravatar fallback.
     183 *                         By default, BP will fall back on Gravatar when it
     184 *                         cannot find a local avatar. In some cases, this may
     185 *                         be undesirable, in which case 'no_grav' should be
     186 *                         set to true. To disable Gravatar fallbacks globally,
     187 *                         see the 'bp_core_fetch_avatar_no_grav' filter.
     188 *                         Default: false.
     189 *     @type bool $html Whether to return an <img> HTML element, vs a raw URL
     190 *                      to an avatar. If false, <img>-specific arguments (like
     191 *                      'css_id') will be ignored. Default: true.
     192 * }
    102193 * @return string Formatted HTML <img> element, or raw avatar URL based on $html arg
    103194 */
Note: See TracChangeset for help on using the changeset viewer.