themes - How to change allowed attachment files extensions

admin2025-06-05  3

I have general question to group of WP themes that allow creating a classified ad websites.

I would like to know which file/part of code/function is responsible for restriction of attachments. These themes allows only images to be attached to the posted ad.

My aim is to expand allowed files format adding the 3d-model files (like .stl, .obj) that cant be execute on the server site and cannnot harm the server.

Thanks in advance

I have general question to group of WP themes that allow creating a classified ad websites.

I would like to know which file/part of code/function is responsible for restriction of attachments. These themes allows only images to be attached to the posted ad.

My aim is to expand allowed files format adding the 3d-model files (like .stl, .obj) that cant be execute on the server site and cannnot harm the server.

Thanks in advance

Share Improve this question asked Dec 18, 2018 at 7:24 SWESWE 11 bronze badge 2
  • You're going to need to ask their authors. They probably all do it in a different way. – Jacob Peattie Commented Dec 18, 2018 at 7:30
  • I have talked to one developer and he said that this group of themes have very similar function structure. I'm just new to Wordpress as well as i am very beginner at modifying code so i would like someone proficient to just show me the direct what i should looking for. – SWE Commented Dec 18, 2018 at 7:41
Add a comment  | 

1 Answer 1

Reset to default 0

I think this may be what your looking for. Below are a few examples of altering the default file types allowed by WordPress. Keep in mind that some hosting companies will disallow some file types.

Allow All File Types

Add the following to wp-config.php to allow for any file type.

define( 'ALLOW_UNFILTERED_UPLOADS', true );

Allow or Disable Specific Types

Add the following code into your theme's functions.php

function my_custom_mime_types( $mimes ) {

    // New allowed mime types.
    $mimes['svg'] = 'image/svg+xml';
    $mimes['svgz'] = 'image/svg+xml';
    $mimes['doc'] = 'application/msword'; 

    // Optional. Remove a mime type.
    unset( $mimes['exe'] );

    return $mimes;
}

add_filter( 'upload_mimes', 'my_custom_mime_types' );

Resources

Allowed mime Types

List of mime Types


Plugins

WP Add Mime Types

Disable Mime Check

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1749087564a316256.html

最新回复(0)