- Timestamp:
- 06/02/2024 07:14:55 PM (20 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/classes/class-bp-attachment-avatar.php
r13414 r13901 32 32 $allowed_types = bp_core_get_allowed_avatar_types(); 33 33 34 parent::__construct( array( 35 'action' => 'bp_avatar_upload', 36 'file_input' => 'file', 37 'original_max_filesize' => bp_core_avatar_original_max_filesize(), 38 39 // Specific errors for avatars. 40 'upload_error_strings' => array( 41 /* translators: %s: Max file size for the profile photo */ 42 9 => sprintf( _x( 'That photo is too big. Please upload one smaller than %s', 'profile photo upload error', 'buddypress' ), size_format( bp_core_avatar_original_max_filesize() ) ), 43 44 /* translators: %s: comma separated list of file types allowed for the profile photo */ 45 10 => sprintf( _nx( 'Please upload only this file type: %s.', 'Please upload only these file types: %s.', count( $allowed_types ), 'profile photo upload error', 'buddypress' ), self::get_avatar_types( $allowed_types ) ), 46 ), 47 ) ); 34 parent::__construct( 35 array( 36 'action' => 'bp_avatar_upload', 37 'file_input' => 'file', 38 'original_max_filesize' => bp_core_avatar_original_max_filesize(), 39 40 // Specific errors for avatars. 41 'upload_error_strings' => array( 42 /* translators: %s: Max file size for the profile photo */ 43 9 => sprintf( _x( 'That photo is too big. Please upload one smaller than %s', 'profile photo upload error', 'buddypress' ), size_format( bp_core_avatar_original_max_filesize() ) ), 44 45 /* translators: %s: comma separated list of file types allowed for the profile photo */ 46 10 => sprintf( _nx( 'Please upload only this file type: %s.', 'Please upload only these file types: %s.', count( $allowed_types ), 'profile photo upload error', 'buddypress' ), self::get_avatar_types( $allowed_types ) ), 47 ), 48 ) 49 ); 48 50 } 49 51 … … 98 100 $file['error'] = 9; 99 101 100 // File is of invalid type.102 // File is of invalid type. 101 103 } elseif ( ! bp_core_check_avatar_type( array( 'file' => $file ) ) ) { 102 104 $file['error'] = 10; … … 153 155 3 => 180, 154 156 6 => -90, 155 8 => 90,157 8 => 90, 156 158 ); 157 159 … … 163 165 if ( empty( $edit_args ) ) { 164 166 return false; 167 } 165 168 166 169 // Add the file to the edit arguments. 167 } else { 168 $edit_args['file'] = $file; 169 } 170 $edit_args['file'] = $file; 170 171 171 172 return parent::edit_image( 'avatar', $edit_args ); … … 176 177 * 177 178 * @since 2.3.0 178 *179 179 * 180 180 * @param string $file the absolute path to the file. … … 186 186 $full_height = bp_core_avatar_full_height(); 187 187 188 if ( isset( $uploaded_image[0] ) && $uploaded_image[0] < $full_width || $uploaded_image[1] < $full_height ) { 189 return true; 190 } 191 192 return false; 188 return ( isset( $uploaded_image[0] ) && ( $uploaded_image[0] < $full_width || $uploaded_image[1] < $full_height ) ); 193 189 } 194 190 … … 198 194 * @since 2.3.0 199 195 * 200 * @see BP_Attachment::cropfor the list of parameters196 * @see BP_Attachment::crop() for the list of parameters 201 197 * 202 198 * @param array $args Array of arguments for the cropping. … … 229 225 230 226 // Bail if the avatar is not available. 231 if ( ! file_exists( $absolute_path ) ) {227 if ( ! file_exists( $absolute_path ) ) { 232 228 return false; 233 229 } … … 281 277 } 282 278 283 $is_full = preg_match( "/-bpfull/", $avatar_file->name );284 $is_thumb = preg_match( "/-bpthumb/", $avatar_file->name );279 $is_full = preg_match( '/-bpfull/', $avatar_file->name ); 280 $is_thumb = preg_match( '/-bpthumb/', $avatar_file->name ); 285 281 286 282 if ( $is_full || $is_thumb ) { … … 322 318 'thumb' => '', 323 319 ); 324 $timestamp = bp_core_current_time( true, 'timestamp' );320 $timestamp = bp_core_current_time( true, 'timestamp' ); 325 321 326 322 foreach ( $avatar_types as $key_type => $type ) { … … 359 355 */ 360 356 private function get_user_id() { 361 $bp = buddypress();357 $bp = buddypress(); 362 358 $user_id = 0; 363 359 … … 424 420 'item_id' => $user_id, 425 421 'has_avatar' => bp_get_user_has_avatar( $user_id ), 426 'nonces' => array(422 'nonces' => array( 427 423 'set' => wp_create_nonce( 'bp_avatar_cropstore' ), 428 424 'remove' => wp_create_nonce( 'bp_delete_avatar_link' ), … … 476 472 477 473 // Include the specific css. 478 $script_data['extra_js'] = $js_scripts;474 $script_data['extra_js'] = $js_scripts; 479 475 480 476 // Set the object to contextualize the filter.
Note: See TracChangeset
for help on using the changeset viewer.