Changeset 7433 for trunk/bp-core/bp-core-avatars.php
- Timestamp:
- 10/16/2013 01:36:51 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-core/bp-core-avatars.php
r7428 r7433 2 2 3 3 /** 4 * BuddyPress Avatars 4 * BuddyPress Avatars. 5 5 */ 6 6 … … 9 9 10 10 /*** 11 * Set up the constants we need for avatar support 11 * Set up the constants we need for avatar support. 12 12 */ 13 13 function bp_core_set_avatar_constants() { … … 51 51 add_action( 'bp_init', 'bp_core_set_avatar_constants', 3 ); 52 52 53 /** 54 * Set up global variables related to avatars. 55 * 56 * @since BuddyPress (1.5.0) 57 */ 53 58 function bp_core_set_avatar_globals() { 54 59 $bp = buddypress(); … … 478 483 479 484 /** 480 * Delete an existing avatar 481 * 482 * Accepted values for $args are: 483 * item_id - item id which relates to the object type. 484 * object - the objetc type user, group, blog, etc. 485 * avatar_dir - The directory where the avatars to be uploaded. 486 * 487 * @param mixed $args 488 * @return bool Success/failure 485 * Delete an existing avatar. 486 * 487 * @param array $args { 488 * Array of function parameters. 489 * @type bool|int $item_id ID of the item whose avatar you're deleting. 490 * Defaults to the current item of type $object. 491 * @type string $object Object type of the item whose avatar you're 492 * deleting. 'user', 'group', 'blog', or custom. Default: 'user'. 493 * @type bool|string $avatar_dir Subdirectory where avatar is located. 494 * Default: false, which falls back on the default location 495 * corresponding to the $object. 496 * } 497 * @return bool True on success, false on failure. 489 498 */ 490 499 function bp_core_delete_existing_avatar( $args = '' ) { … … 546 555 547 556 /** 548 * Handles avatar uploading. 549 * 550 * The functions starts off by checking that the file has been uploaded properly using bp_core_check_avatar_upload(). 551 * It then checks that the file size is within limits, and that it has an accepted file extension (jpg, gif, png). 552 * If everything checks out, crop the image and move it to its real location. 553 * 554 * @param array $file The appropriate entry the from $_FILES superglobal. 555 * @param string $upload_dir_filter A filter to be applied to upload_dir 556 * @return bool Success/failure 557 * Handle avatar uploading. 558 * 559 * The functions starts off by checking that the file has been uploaded 560 * properly using bp_core_check_avatar_upload(). It then checks that the file 561 * size is within limits, and that it has an accepted file extension (jpg, gif, 562 * png). If everything checks out, crop the image and move it to its real 563 * location. 564 * 557 565 * @see bp_core_check_avatar_upload() 558 566 * @see bp_core_check_avatar_type() 567 * 568 * @param array $file The appropriate entry the from $_FILES superglobal. 569 * @param string $upload_dir_filter A filter to be applied to 'upload_dir'. 570 * @return bool True on success, false on failure. 559 571 */ 560 572 function bp_core_avatar_handle_upload( $file, $upload_dir_filter ) { … … 672 684 673 685 /** 674 * Crop an uploaded avatar 686 * Crop an uploaded avatar. 675 687 * 676 688 * $args has the following parameters: … … 684 696 * crop_y - The vertical starting point of the crop 685 697 * 686 * @param mixed $args 687 * @return bool Success/failure 698 * @param array $args { 699 * Array of function parameters. 700 * @type string $object Object type of the item whose avatar you're 701 * handling. 'user', 'group', 'blog', or custom. Default: 'user'. 702 * @type string $avatar_dir Subdirectory where avatar should be stored. 703 * Default: 'avatars'. 704 * @type bool|int $item_id ID of the item that the avatar belongs to. 705 * @type bool|string $original_file Absolute papth to the original avatar 706 * file. 707 * @type int $crop_w Crop width. Default: the global 'full' avatar width, 708 * as retrieved by bp_core_avatar_full_width(). 709 * @type int $crop_h Crop height. Default: the global 'full' avatar height, 710 * as retrieved by bp_core_avatar_full_height(). 711 * @type int $crop_x The horizontal starting point of the crop. Default: 0. 712 * @type int $crop_y The vertical starting point of the crop. Default: 0. 713 * } 714 * @return bool True on success, false on failure. 688 715 */ 689 716 function bp_core_avatar_handle_crop( $args = '' ) { … … 764 791 765 792 /** 766 * bp_core_fetch_avatar_filter() 767 * 768 * Attempts to filter get_avatar function and let BuddyPress have a go 769 * at finding an avatar that may have been uploaded locally. 770 * 771 * @global array $authordata 772 * @param string $avatar The result of get_avatar from before-filter 773 * @param int|string|object $user A user ID, email address, or comment object 774 * @param int $size Size of the avatar image (thumb/full) 775 * @param string $default URL to a default image to use if no avatar is available 776 * @param string $alt Alternate text to use in image tag. Defaults to blank 777 * @return string 793 * Replace default WordPress avatars with BP avatars, if available. 794 * 795 * Filters 'get_avatar'. 796 * 797 * @param string $avatar The avatar path passed to 'get_avatar'. 798 * @param int|string|object $user A user ID, email address, or comment object. 799 * @param int $size Size of the avatar image ('thumb' or 'full'). 800 * @param string $default URL to a default image to use if no avatar is available. 801 * @param string $alt Alternate text to use in image tag. Default: ''. 802 * @return string BP avatar path, if found; else the original avatar path. 778 803 */ 779 804 function bp_core_fetch_avatar_filter( $avatar, $user, $size, $default, $alt = '' ) { … … 816 841 817 842 /** 818 * Has the current avatar upload generated an error?819 * 820 * @param array $file 821 * @return bool 843 * Is the current avatar upload error-free? 844 * 845 * @param array $file The $_FILES array. 846 * @return bool True if no errors are found. False if there are errors. 822 847 */ 823 848 function bp_core_check_avatar_upload( $file ) { … … 831 856 * Is the file size of the current avatar upload permitted? 832 857 * 833 * @param array $file 834 * @return bool 858 * @param array $file The $_FILES array. 859 * @return bool True if the avatar is under the size limit, otherwise false. 835 860 */ 836 861 function bp_core_check_avatar_size( $file ) { … … 846 871 * Permitted file types are JPG, GIF and PNG. 847 872 * 848 * @param string $file849 * @return bool 873 * @param array $file The $_FILES array. 874 * @return bool True if the file extension is permitted, otherwise false. 850 875 */ 851 876 function bp_core_check_avatar_type($file) { … … 857 882 858 883 /** 859 * Fetch esdata from the BP root blog's upload directory.884 * Fetch data from the BP root blog's upload directory. 860 885 * 861 886 * Handy for multisite instances because all uploads are made on the BP root … … 865 890 * once to get what we need. 866 891 * 867 * @since BuddyPress (1.8 )892 * @since BuddyPress (1.8.0) 868 893 * 869 894 * @uses wp_upload_dir() 870 895 * 871 * @param string $type The variable we want to return from the $bp->avatars object.872 * Only 'upload_path' and 'url' are supported.873 * @return string 896 * @param string $type The variable we want to return from the $bp->avatars 897 * object. Only 'upload_path' and 'url' are supported. Default: 'upload_path'. 898 * @return string The avatar upload directory path. 874 899 */ 875 900 function bp_core_get_upload_dir( $type = 'upload_path' ) { … … 949 974 950 975 /** 951 * bp_core_avatar_upload_path() 952 * 953 * Returns the absolute upload path for the WP installation 976 * Get the absolute upload path for the WP installation. 954 977 * 955 978 * @uses wp_upload_dir To get upload directory info 956 * @return string Absolute path to WP upload directory 979 * 980 * @return string Absolute path to WP upload directory. 957 981 */ 958 982 function bp_core_avatar_upload_path() { … … 961 985 962 986 /** 963 * bp_core_avatar_url() 964 * 965 * Returns the raw base URL for root site upload location 966 * 967 * @uses wp_upload_dir To get upload directory info 968 * @return string Full URL to current upload location 987 * Get the raw base URL for root site upload location. 988 * 989 * @uses wp_upload_dir To get upload directory info. 990 * 991 * @return string Full URL to current upload location. 969 992 */ 970 993 function bp_core_avatar_url() { … … 973 996 974 997 /** 975 * Check if a given user ID has an uploaded avatar 976 * 977 * @since BuddyPress (1.0) 978 * @param int $user_id 979 * @return boolean 998 * Check if a given user ID has an uploaded avatar. 999 * 1000 * @since BuddyPress (1.0.0) 1001 * 1002 * @param int $user_id ID of the user whose avatar is being checked. 1003 * @return bool True if the user has uploaded a local avatar. Otherwise false. 980 1004 */ 981 1005 function bp_get_user_has_avatar( $user_id = 0 ) { … … 992 1016 993 1017 /** 994 * Utility function for fetching an avatar dimension setting 995 * 996 * @package BuddyPress 997 * @since BuddyPress (1.5) 998 * 999 * @param string $type 'thumb' for thumbs, otherwise full 1000 * @param string $h_or_w 'height' for height, otherwise width 1001 * @return int $dim The dimension 1018 * Utility function for fetching an avatar dimension setting. 1019 * 1020 * @since BuddyPress (1.5.0) 1021 * 1022 * @param string $type Dimension type you're fetching dimensions for. 'thumb' 1023 * or 'full'. Default: 'thumb'. 1024 * @param string $h_or_w Which dimension is being fetched. 'height' or 'width'. 1025 * Default: 'height'. 1026 * @return int $dim The dimension. 1002 1027 */ 1003 1028 function bp_core_avatar_dimension( $type = 'thumb', $h_or_w = 'height' ) { … … 1009 1034 1010 1035 /** 1011 * Get the avatar thumb width setting 1012 * 1013 * @package BuddyPress 1014 * @since BuddyPress (1.5) 1015 * 1016 * @return int The thumb width 1036 * Get the 'thumb' avatar width setting. 1037 * 1038 * @since BuddyPress (1.5.0) 1039 * 1040 * @return int The 'thumb' width. 1017 1041 */ 1018 1042 function bp_core_avatar_thumb_width() { … … 1021 1045 1022 1046 /** 1023 * Get the avatar thumb height setting 1024 * 1025 * @package BuddyPress 1026 * @since BuddyPress (1.5) 1027 * 1028 * @return int The thumb height 1047 * Get the 'thumb' avatar height setting. 1048 * 1049 * @since BuddyPress (1.5.0) 1050 * 1051 * @return int The 'thumb' height. 1029 1052 */ 1030 1053 function bp_core_avatar_thumb_height() { … … 1033 1056 1034 1057 /** 1035 * Get the avatar full width setting 1036 * 1037 * @package BuddyPress 1038 * @since BuddyPress (1.5) 1039 * 1040 * @return int The full width 1058 * Get the 'full' avatar width setting 1059 * 1060 * @since BuddyPress (1.5.0) 1061 * 1062 * @return int The 'full' width. 1041 1063 */ 1042 1064 function bp_core_avatar_full_width() { … … 1045 1067 1046 1068 /** 1047 * Get the avatar full height setting 1048 * 1049 * @package BuddyPress 1050 * @since BuddyPress (1.5) 1051 * 1052 * @return int The full height 1069 * Get the 'full' avatar height setting. 1070 * 1071 * @since BuddyPress (1.5.0) 1072 * 1073 * @return int The 'full' height. 1053 1074 */ 1054 1075 function bp_core_avatar_full_height() { … … 1057 1078 1058 1079 /** 1059 * Get the max width for original avatar uploads 1060 * 1061 * @package BuddyPress 1062 * @since BuddyPress (1.5) 1063 * 1064 * @return int The width 1080 * Get the max width for original avatar uploads. 1081 * 1082 * @since BuddyPress (1.5.0) 1083 * 1084 * @return int The max width for original avatar uploads. 1065 1085 */ 1066 1086 function bp_core_avatar_original_max_width() { … … 1069 1089 1070 1090 /** 1071 * Get the max filesize for original avatar uploads 1072 * 1073 * @package BuddyPress 1074 * @since BuddyPress (1.5) 1075 * 1076 * @return int The filesize 1091 * Get the max filesize for original avatar uploads. 1092 * 1093 * @since BuddyPress (1.5.0) 1094 * 1095 * @return int The max filesize for original avatar uploads. 1077 1096 */ 1078 1097 function bp_core_avatar_original_max_filesize() { … … 1081 1100 1082 1101 /** 1083 * Get the default avatar 1084 * 1085 * @package BuddyPress 1086 * @since BuddyPress (1.5) 1087 * 1088 * @return int The URL of the default avatar 1102 * Get the URL of the 'full' default avatar. 1103 * 1104 * @since BuddyPress (1.5.0) 1105 * 1106 * @return string The URL of the default avatar. 1089 1107 */ 1090 1108 function bp_core_avatar_default() { … … 1093 1111 1094 1112 /** 1095 * Get the default avatar thumb 1096 * 1097 * @package BuddyPress 1098 * @since BuddyPress (1.5) 1099 * 1100 * @return int The URL of the default avatar thumb 1113 * Get the URL of the 'thumb' default avatar. 1114 * 1115 * @since BuddyPress (1.5.0) 1116 * 1117 * @return string The URL of the default avatar thumb. 1101 1118 */ 1102 1119 function bp_core_avatar_default_thumb() {
Note: See TracChangeset
for help on using the changeset viewer.