【问题标题】:Upload webp Images from admin side - Wordpress从管理员端上传 webp 图片 - Wordpress
【发布时间】:2019-01-04 08:16:52
【问题描述】:

我将未过滤的上传添加到 wp-config 仍然没有上传 webp。但它适用于其他文件,如 gif、rar.zip

【问题讨论】:

    标签: wordpress webp


    【解决方案1】:

    试试这个功能

    function webp_upload_mimes( $existing_mimes ) {
    // add webp to the list of mime types
    $existing_mimes['webp'] = 'image/webp';
    // return the array back to the function with our added mime type
    return $existing_mimes;
    }
    add_filter( 'mime_types', 'webp_upload_mimes' );
    

    【讨论】:

      【解决方案2】:

      您需要在上传时添加mime类型,您可以使用以下功能实现。

              add_filter( 'mime_types', 'webp_upload_mimes' ); 
              function webp_file_upload( $mimes ) 
              {
                  $mimes['webp'] = 'image/webp'; // add webp in mime type
                  return $mimes; // return the mime types
              }
      

      希望这对你有用

      【讨论】:

        猜你喜欢
        • 2013-09-07
        • 2014-05-17
        • 1970-01-01
        • 1970-01-01
        • 2017-08-02
        • 2014-09-25
        • 2015-06-29
        • 2021-09-23
        • 1970-01-01
        相关资源
        最近更新 更多