diff --git a/src/bp-core/bp-core-attachments.php b/src/bp-core/bp-core-attachments.php
index 2663dde..f0ddaa2 100644
a
|
b
|
function bp_attachments_get_attachment( $data = 'url', $args = array() ) { |
410 | 410 | 'file' => '', |
411 | 411 | ), 'attachments_get_attachment_src' ); |
412 | 412 | |
| 413 | /** |
| 414 | * Filters whether or not to handle fetching a BuddyPress image attachment. |
| 415 | * |
| 416 | * If you want to override this function, make sure you return false. |
| 417 | * |
| 418 | * @since 2.5.1 |
| 419 | * |
| 420 | * @param null|string $value If null is returned, proceed with default behaviour. Otherwise, value returned verbatim. |
| 421 | * @param array $r { |
| 422 | * @type string $object_dir The object dir (eg: members/groups). Defaults to members. |
| 423 | * @type int $item_id The object id (eg: a user or a group id). Defaults to current user. |
| 424 | * @type string $type The type of the attachment which is also the subdir where files are saved. |
| 425 | * Defaults to 'cover-image' |
| 426 | * @type string $file The name of the file. |
| 427 | * } |
| 428 | */ |
| 429 | $pre_filter = apply_filters( 'bp_attachments_pre_get_attachment', null, $r ); |
| 430 | if ( $pre_filter !== null ) { |
| 431 | return $pre_filter; |
| 432 | } |
| 433 | |
413 | 434 | // Get BuddyPress Attachments Uploads Dir datas. |
414 | 435 | $bp_attachments_uploads_dir = bp_attachments_uploads_dir_get(); |
415 | 436 | |
… |
… |
function bp_attachments_get_attachment( $data = 'url', $args = array() ) { |
478 | 499 | function bp_attachments_delete_file( $args = array() ) { |
479 | 500 | $attachment_path = bp_attachments_get_attachment( 'path', $args ); |
480 | 501 | |
| 502 | /** |
| 503 | * Filters whether or not to handle deleting an existing BuddyPress attachment. |
| 504 | * |
| 505 | * If you want to override this function, make sure you return false. |
| 506 | * |
| 507 | * @since 2.5.1 |
| 508 | * |
| 509 | * @param bool $value Whether or not to delete the BuddyPress attachment. |
| 510 | * @param array Array of arguments for the attachment deletion. |
| 511 | */ |
| 512 | if ( ! apply_filters( 'bp_attachments_pre_delete_file', true, $args ) ) { |
| 513 | return true; |
| 514 | } |
| 515 | |
481 | 516 | if ( empty( $attachment_path ) ) { |
482 | 517 | return false; |
483 | 518 | } |
… |
… |
function bp_attachments_cover_image_ajax_upload() { |
1223 | 1258 | bp_attachments_json_response( false, $is_html4 ); |
1224 | 1259 | } |
1225 | 1260 | |
| 1261 | /** |
| 1262 | * Filters whether or not to handle cover image uploading. |
| 1263 | * |
| 1264 | * If you want to override this function, make sure you return false. |
| 1265 | * |
| 1266 | * @since 2.5.1 |
| 1267 | * |
| 1268 | * @param bool $value Whether or not to crop. |
| 1269 | * @param array $bp_params |
| 1270 | * @param array $needs_reset Stores original value of certain globals we need to revert to later. |
| 1271 | * @param array $object_data |
| 1272 | */ |
| 1273 | if ( ! apply_filters( 'bp_attachments_pre_cover_image_ajax_upload', true, $bp_params, $needs_reset, $object_data ) ) { |
| 1274 | return true; |
| 1275 | } |
| 1276 | |
1226 | 1277 | $cover_image_attachment = new BP_Attachment_Cover_Image(); |
1227 | 1278 | $uploaded = $cover_image_attachment->upload( $_FILES ); |
1228 | 1279 | |
diff --git a/src/bp-core/bp-core-avatars.php b/src/bp-core/bp-core-avatars.php
index 6529d14..64a9e43 100644
a
|
b
|
function bp_core_delete_existing_avatar( $args = '' ) { |
703 | 703 | $args = wp_parse_args( $args, $defaults ); |
704 | 704 | extract( $args, EXTR_SKIP ); |
705 | 705 | |
| 706 | /** |
| 707 | * Filters whether or not to handle deleting an existing avatar. |
| 708 | * |
| 709 | * If you want to override this function, make sure you return false. |
| 710 | * |
| 711 | * @since 2.5.1 |
| 712 | * |
| 713 | * @param bool $value Whether or not to delete the avatar. |
| 714 | * @param array $args { |
| 715 | * Array of function parameters. |
| 716 | * |
| 717 | * @type bool|int $item_id ID of the item whose avatar you're deleting. |
| 718 | * Defaults to the current item of type $object. |
| 719 | * @type string $object Object type of the item whose avatar you're |
| 720 | * deleting. 'user', 'group', 'blog', or custom. |
| 721 | * Default: 'user'. |
| 722 | * @type bool|string $avatar_dir Subdirectory where avatar is located. |
| 723 | * Default: false, which falls back on the default location |
| 724 | * corresponding to the $object. |
| 725 | * } |
| 726 | */ |
| 727 | if ( ! apply_filters( 'bp_core_pre_delete_existing_avatar', true, $args ) ) { |
| 728 | return true; |
| 729 | } |
| 730 | |
706 | 731 | if ( empty( $item_id ) ) { |
707 | 732 | if ( 'user' == $object ) |
708 | 733 | $item_id = bp_displayed_user_id(); |
… |
… |
function bp_avatar_handle_capture( $data = '', $item_id = 0 ) { |
1069 | 1094 | return false; |
1070 | 1095 | } |
1071 | 1096 | |
| 1097 | /** |
| 1098 | * Filters whether or not to handle avatar webcam capture. |
| 1099 | * |
| 1100 | * If you want to override this function, make sure you return false. |
| 1101 | * |
| 1102 | * @since 2.5.1 |
| 1103 | * |
| 1104 | * @param bool $value Whether or not to crop. |
| 1105 | * @param string $data Base64 encoded image. |
| 1106 | * @param int $item_id Item to associate. |
| 1107 | */ |
| 1108 | if ( ! apply_filters( 'bp_avatar_pre_handle_capture', true, $data, $item_id ) ) { |
| 1109 | return true; |
| 1110 | } |
| 1111 | |
1072 | 1112 | $avatar_dir = bp_core_avatar_upload_path() . '/avatars'; |
1073 | 1113 | |
1074 | 1114 | // It's not a regular upload, we may need to create this folder. |