wordpress修改上传文件默认类型

这段代码让你添加或移除WordPress上传弹出允许的文件类型。比如添加字体文woff默认是不允许的,而下面的代码轻松的让你实现。

把以下代码加到 functions.php 文件中

function edit_upload_types($existing_mimes = array()) {
    // allow .woff
    $existing_mimes['woff'] = 'font/woff';
 
    // add as many as you want with the same syntax
 
    // disallow .jpg files
    unset( $existing_mimes['jpg'] );
 
    return $existing_mimes;
}
add_filter('upload_mimes', 'edit_upload_types');

分享到:

用微信扫一扫,分享给朋友


发布日期:

所属分类: Wordpress 综合