Skip to:
Content

BuddyPress.org

Changeset 13132


Ignore:
Timestamp:
10/30/2021 11:59:17 AM (5 years ago)
Author:
imath
Message:

Improve the bp_attachments_get_allowed_types() function

  • Make sure requesting for the 'audio' type returns a list of audio file extensions.
  • Use the wp_get_ext_types() function so that passing the 'image', 'document', 'spreadsheet', 'interactive', 'text', 'archive', 'code' types to the function will return the requested type extensions.

Fixes #8595

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/bp-core-attachments.php

    r13108 r13132  
    164164function bp_attachments_get_allowed_types( $type = 'avatar' ) {
    165165        // Defaults to BuddyPress supported image extensions.
    166         $exts = array( 'jpeg', 'gif', 'png' );
     166        $exts    = array( 'jpeg', 'gif', 'png' );
     167        $wp_exts = wp_get_ext_types();
    167168
    168169        /**
    … …  
    175176
    176177                switch ( $type ) {
    177                         case 'video' :
     178                        case 'video':
    178179                                $exts = wp_get_video_extensions();
    179180                        break;
    180181
    181                         case 'audio' :
    182                                 $exts = wp_get_video_extensions();
     182                        case 'audio':
     183                                $exts = wp_get_audio_extensions();
     184                        break;
     185
     186                        case isset( $wp_exts[ $type ] ):
     187                                $exts = $wp_exts[ $type ];
    183188                        break;
    184189
Note: See TracChangeset for help on using the changeset viewer.