支持 » 意见建议 » 附件显示设置BUG

  • 使用以下代码增加对WebP的支持后,上传WebP文件时,文件窗口右侧的附件详情里,附件显示设置的“链接到”选项始终为默认选择“媒体文件(file)”,但在HTML源码里可以看到默认selected是在“无(none)”的选项,只有在文件上传成功后刷新页面,才会默认设置为“无(none)”。并且数据库中的image_default_link_type的值并不能影响该设置。

    add_filter(‘mime_types’, function($array) {
    $tmp[‘webp’] = ‘image/webp’;
    $array = wp_parse_args($array, $tmp);
    return $array;
    }, 10, 1);

    add_filter(‘file_is_displayable_image’, function($result, $path) {
    $mime = mime_content_type($path);
    if(‘image/webp’ == $mime) {
    $result = true;
    }
    return $result;
    }, 10, 2);

    add_filter(‘ext2type’, function($arrays) {
    array_unshift($arrays[‘image’], ‘webp’);
    return $arrays;
    }, 10, 1);

    • 该话题由背字根 于 4年、 2月前 修正。
  • 话题 ‘附件显示设置BUG’不再接受新回复。