Changeset 13315 for trunk/src/bp-core/bp-core-attachments.php
- Timestamp:
- 08/13/2022 12:16:46 PM (3 years ago)
- File:
-
- 1 edited
-
trunk/src/bp-core/bp-core-attachments.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/bp-core-attachments.php
r13263 r13315 157 157 * 158 158 * @since 2.4.0 159 * @since 11.0.0 Adds the support for .webp images to Avatars and Cover images. 159 160 * 160 161 * @param string $type The extension types to get. … … 164 165 function bp_attachments_get_allowed_types( $type = 'avatar' ) { 165 166 // Defaults to BuddyPress supported image extensions. 166 $exts = array( 'jpeg', 'gif', 'png' ); 167 $wp_exts = wp_get_ext_types(); 168 169 /** 170 * It's not a BuddyPress feature, get the allowed extensions 171 * matching the $type requested. 172 */ 173 if ( 'avatar' !== $type && 'cover_image' !== $type ) { 167 $exts = array( 'jpg', 'jpeg', 'jpe', 'gif', 'png' ); 168 if ( bp_is_running_wp( '5.8.0', '>=' ) ) { 169 $exts[] = 'webp'; 170 } 171 172 // Avatar and cover image are images. 173 if ( 'image' !== $type && 'avatar' !== $type && 'cover_image' !== $type ) { 174 174 // Reset the default exts. 175 $exts = array(); 175 $exts = array(); 176 $wp_exts = wp_get_ext_types(); 176 177 177 178 if ( 'video' === $type ) { … … 690 691 'crunching' => __( 'Crunching…', 'buddypress' ), 691 692 'unique_file_warning' => __( 'Make sure to upload a unique file', 'buddypress' ), 693 'noneditable_image' => __( 'This image cannot be processed by the web server. Convert it to JPEG or PNG before uploading.', 'buddypress' ), 692 694 693 695 /* translators: %s: File name. */ … … 778 780 if ( ! empty( $args['max_file_size'] ) ) { 779 781 $defaults['filters']['max_file_size'] = $args['max_file_size'] . 'b'; 782 } 783 784 if ( isset( $args['mime_types'] ) && $args['mime_types'] ) { 785 $defaults['filters']['mime_types'] = array( array( 'extensions' => $args['mime_types'] ) ); 786 } 787 788 // Check if WebP images can be edited. 789 if ( bp_is_running_wp( '5.8.0', '>=' ) && ! wp_image_editor_supports( array( 'mime_type' => 'image/webp' ) ) ) { 790 $defaults['webp_upload_error'] = true; 780 791 } 781 792
Note: See TracChangeset
for help on using the changeset viewer.