May 2017
Beginner to intermediate
536 pages
14h 25m
English
Usually, we do allow the .jpg, .jpeg, .png, and .gif types in the WordPress media uploader. However, there can be occasions where we need more control over the allowed file types. So, let's see how we can change the allowed file types within WordPress. Add the following line of code to the instance function of the WPWA_File_Uploader class:
add_filter( 'upload_mimes', array( self::$instance , 'filter_mime_types' ) );
Now, let's consider the implementation of the filter_mime_types function for the file type restricting process:
public function filter_mime_types( $mimes ) { $mimes = array( 'jpg|jpeg|jpe' => 'image/jpeg', 'pdf' => 'application/pdf' ); return $mimes; }
WordPress passes existing mime ...
Read now
Unlock full access