无法使用wordpress上传otf文件

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了无法使用wordpress上传otf文件相关的知识,希望对你有一定的参考价值。

我试图使用wp_handle_upload()上传wordpress上传中的字体文件

为了允许类型的字体文件,我在functions.php中添加了以下代码

  function allow_font_mime_types($mimes) {
  $mimes['eot']   = 'application/vnd.ms-fontobject';
  $mimes['woff']  = 'application/font-woff'; 
  $mimes['otf']   = 'application/vnd.oasis.opendocument.formula-template';
  $mimes['svg']   = 'image/svg+xml';

  return $mimes;
}
add_filter('upload_mimes', 'allow_font_mime_types'); 

除了otf之外的所有文件都已上传。但是当我们尝试uload otf时,它会抛出一个错误

出于安全原因,不允许使用此文件类型

答案

我认为它可能会对你有所帮助

$ mimes ['otf'] ='application / font-sfnt';

或者使用这个插件 - https://wordpress.org/plugins/use-any-font/

以上是关于无法使用wordpress上传otf文件的主要内容,如果未能解决你的问题,请参考以下文章