Home / Attachments / File Upload Type
Duplicate Snippet

Embed Snippet on Your Site

File Upload Type

Overrides the default allowed upload file types — anything not listed will be rejected with "Sorry, this file type is not permitted for security reasons."

Code Preview
php
<?php
// File Upload Type / Kiri Vadivelu / 2026
add_filter( 'upload_mimes', function( $mimes ) {
    return array(
        'jpg|jpeg|jpe' => 'image/jpeg',
        'png'          => 'image/png',
        'ico'          => 'image/x-icon',
        'webp'         => 'image/webp',
        'pdf'          => 'application/pdf',
        // 'mp3'          => 'audio/mpeg',
        // 'mp4|m4v'      => 'video/mp4',
        // 'doc|docx'     => 'application/msword'  
    );
} );  

Comments

Add a Comment