Changeset 6601
- Timestamp:
- 12/10/2012 01:00:26 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-core/bp-core-avatars.php
r6600 r6601 110 110 111 111 // Set the default variables array 112 $ defaults =array(112 $params = wp_parse_args( $args, array( 113 113 'item_id' => false, 114 114 'object' => $def_object, // user/group/blog/custom type (if you use filters) … … 124 124 'html' => true, // Wrap the return img URL in <img /> 125 125 'title' => '' // Custom <img> title (string) 126 ); 127 128 // Compare defaults to passed and extract 129 $params = wp_parse_args( $args, $defaults ); 126 ) ); 130 127 extract( $params, EXTR_SKIP ); 131 128 … … 200 197 if ( false !== strpos( $alt, '%s' ) || false !== strpos( $alt, '%1$s' ) ) { 201 198 202 // Get item name for alt/title tags203 $item_name = '';204 205 199 switch ( $object ) { 206 200 … … 229 223 $alt = __( 'Avatar Image', 'buddypress' ); 230 224 225 $html_alt = ' alt="' . esc_attr( $alt ) . '"'; 226 231 227 // Set title tag, if it's been provided 232 if ( !empty( $title ) ) 228 if ( !empty( $title ) ) { 233 229 $title = " title='" . esc_attr( apply_filters( 'bp_core_avatar_title', $title, $item_id, $object, $params ) ) . "'"; 230 } 234 231 235 232 // Set CSS ID if passed 236 if ( !empty( $css_id ) ) 237 $css_id = ' id="' . $css_id . '"'; 233 if ( !empty( $css_id ) ) { 234 $css_id = ' id="' . esc_attr( $css_id ) . '"'; 235 } 238 236 239 237 // Set image width 240 if ( false !== $width ) 238 if ( false !== $width ) { 241 239 $html_width = ' width="' . $width . '"'; 242 else 243 $html_width = ( 'thumb' == $type ) ? ' width="' . bp_core_avatar_thumb_width() . '"' : ' width="' . bp_core_avatar_full_width() . '"'; 240 } elseif ( 'thumb' == $type ) { 241 $html_width = ' width="' . bp_core_avatar_thumb_width() . '"'; 242 } else { 243 $html_width = ' width="' . bp_core_avatar_full_width() . '"'; 244 } 244 245 245 246 // Set image height 246 if ( false !== $height ) 247 if ( false !== $height ) { 247 248 $html_height = ' height="' . $height . '"'; 248 else 249 $html_height = ( 'thumb' == $type ) ? ' height="' . bp_core_avatar_thumb_height() . '"' : ' height="' . bp_core_avatar_full_height() . '"'; 249 } elseif ( 'thumb' == $type ) { 250 $html_height = ' height="' . bp_core_avatar_thumb_height() . '"'; 251 } else { 252 $html_height = ' height="' . bp_core_avatar_full_height() . '"'; 253 } 250 254 251 255 // Set img URL and DIR based on prepopulated constants … … 259 263 260 264 // Add an identifying class 261 $class .= ' ' . $object . '-' . $item_id . '-avatar ';262 263 /** **265 $class .= ' ' . $object . '-' . $item_id . '-avatar ' . sanitize_html_class( "avatar-$width" ) . ' photo'; 266 267 /** 264 268 * Look for uploaded avatar first. Use it if it exists. 265 269 * Set the file names to search for, to select the full size … … 323 327 // Return it wrapped in an <img> element 324 328 if ( true === $html ) { 325 return apply_filters( 'bp_core_fetch_avatar', '<img src="' . $avatar_url . '" alt="' . esc_attr( $alt ) . '" class="' . esc_attr( $class ) . '"' . $css_id . $html_width . $html_height . $title . ' />', $params, $item_id, $avatar_dir, $css_id, $html_width, $html_height, $avatar_folder_url, $avatar_folder_dir );326 329 return apply_filters( 'bp_core_fetch_avatar', '<img src="' . $avatar_url . '" class="' . esc_attr( $class ) . '"' . $css_id . $html_width . $html_height . $html_alt . $title . ' />', $params, $item_id, $avatar_dir, $css_id, $html_width, $html_height, $avatar_folder_url, $avatar_folder_dir ); 330 327 331 // ...or only the URL 328 332 } else { … … 365 369 366 370 // Set host based on if using ssl 367 $host = 'http:// www.gravatar.com/avatar/';371 $host = 'http://gravatar.com/avatar/'; 368 372 if ( is_ssl() ) { 369 373 $host = 'https://secure.gravatar.com/avatar/'; … … 376 380 // Gravatar rating; http://bit.ly/89QxZA 377 381 $rating = get_option( 'avatar_rating' ); 378 if ( ! empty( $rating ) ) 382 if ( ! empty( $rating ) ) { 379 383 $gravatar .= "&r={$rating}"; 384 } 380 385 381 386 // No avatar was found, and we've been told not to use a gravatar. … … 384 389 } 385 390 386 if ( true === $html ) 387 return apply_filters( 'bp_core_fetch_avatar', '<img src="' . esc_attr( $gravatar ) . '" alt="' . esc_attr( $alt ) . '" class="' . esc_attr( $class ) . '"' . $css_id . $html_width . $html_height . $title . ' />', $params, $item_id, $avatar_dir, $css_id, $html_width, $html_height, $avatar_folder_url, $avatar_folder_dir );388 else391 if ( true === $html ) { 392 return apply_filters( 'bp_core_fetch_avatar', '<img src="' . $gravatar . '" class="' . esc_attr( $class ) . '"' . $css_id . $html_width . $html_height . $html_alt . $title . ' />', $params, $item_id, $avatar_dir, $css_id, $html_width, $html_height, $avatar_folder_url, $avatar_folder_dir ); 393 } else { 389 394 return apply_filters( 'bp_core_fetch_avatar_url', $gravatar ); 395 } 390 396 } 391 397
Note: See TracChangeset
for help on using the changeset viewer.