Changeset 4462 for trunk/bp-core/bp-core-avatars.php
- Timestamp:
- 06/05/2011 08:26:32 PM (14 years ago)
- File:
-
- 1 edited
-
trunk/bp-core/bp-core-avatars.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-core/bp-core-avatars.php
r4400 r4462 279 279 } 280 280 281 /** 282 * Delete an existing avatar 283 * 284 * Accepted values for $args are: 285 * item_id - item id which relates to the object type. 286 * object - the objetc type user, group, blog, etc. 287 * avatar_dir - The directory where the avatars to be uploaded. 288 * 289 * @global object $bp BuddyPress global settings 290 * @param mixed $args 291 * @return bool Success/failure 292 */ 281 293 function bp_core_delete_existing_avatar( $args = '' ) { 282 294 global $bp; … … 337 349 } 338 350 351 /** 352 * Handles avatar uploading. 353 * 354 * The functions starts off by checking that the file has been uploaded properly using bp_core_check_avatar_upload(). 355 * It then checks that the file size is within limits, and that it has an accepted file extension (jpg, gif, png). 356 * If everything checks out, crop the image and move it to its real location. 357 * 358 * @global object $bp BuddyPress global settings 359 * @param array $file The appropriate entry the from $_FILES superglobal. 360 * @param string $upload_dir_filter A filter to be applied to upload_dir 361 * @return bool Success/failure 362 * @see bp_core_check_avatar_upload() 363 * @see bp_core_check_avatar_type() 364 */ 339 365 function bp_core_avatar_handle_upload( $file, $upload_dir_filter ) { 340 366 global $bp; … … 422 448 } 423 449 450 /** 451 * Crop an uploaded avatar 452 * 453 * $args has the following parameters: 454 * object - What component the avatar is for, e.g. "user" 455 * avatar_dir The absolute path to the avatar 456 * item_id - Item ID 457 * original_file - The absolute path to the original avatar file 458 * crop_w - Crop width 459 * crop_h - Crop height 460 * crop_x - The horizontal starting point of the crop 461 * crop_y - The vertical starting point of the crop 462 * 463 * @global object $bp BuddyPress global settings 464 * @param mixed $args 465 * @return bool Success/failure 466 */ 424 467 function bp_core_avatar_handle_crop( $args = '' ) { 425 468 global $bp; … … 538 581 add_filter( 'get_avatar', 'bp_core_fetch_avatar_filter', 10, 5 ); 539 582 540 function bp_core_check_avatar_upload($file) { 583 /** 584 * Has the current avatar upload generated an error? 585 * 586 * @param array $file 587 * @return bool 588 */ 589 function bp_core_check_avatar_upload( $file ) { 541 590 if ( isset( $file['error'] ) && $file['error'] ) 542 591 return false; … … 545 594 } 546 595 547 function bp_core_check_avatar_size($file) { 596 /** 597 * Is the file size of the current avatar upload permitted? 598 * 599 * @param array $file 600 * @return bool 601 */ 602 function bp_core_check_avatar_size( $file ) { 548 603 if ( $file['file']['size'] > BP_AVATAR_ORIGINAL_MAX_FILESIZE ) 549 604 return false; … … 552 607 } 553 608 609 /** 610 * Does the current avatar upload have an allowed file type? 611 * 612 * Permitted file types are JPG, GIF and PNG. 613 * 614 * @param string $file 615 * @return bool 616 */ 554 617 function bp_core_check_avatar_type($file) { 555 618 if ( ( !empty( $file['file']['type'] ) && !preg_match('/(jpe?g|gif|png)$/i', $file['file']['type'] ) ) || !preg_match( '/(jpe?g|gif|png)$/i', $file['file']['name'] ) )
Note: See TracChangeset
for help on using the changeset viewer.