gpt4 book ai didi

WordPress 和 SVG

转载 作者:行者123 更新时间:2023-12-01 10:51:15 28 4
gpt4 key购买 nike

有谁知道如何让 wordpress 允许使用通过主题定制器面板上传的 SVG 文件?

将以下内容添加到允许上传 SVG 的主题 functions.php 文件(尽管没有预览或特色图像)。

function custom_mtypes( $m ){
$m['svg'] = 'image/svg+xml';
$m['svgz'] = 'image/svg+xml';
return $m;
}
add_filter( 'upload_mimes', 'custom_mtypes' );

但是,这仍然不允许我从文件系统上传或选择 SVG 或拖放一个。

最佳答案

您可以通过将其添加到您当前的主题 functions.php 文件来克服安全警告。

add_filter('upload_mimes', 'custom_upload_mimes');

function custom_upload_mimes ( $existing_mimes=array() ) {
// add the file extension to the array
$existing_mimes['svg'] = 'mime/type';
// call the modified list of extensions
return $existing_mimes;
}

然后你应该能够上传带有 .svg 扩展名的文件

关于WordPress 和 SVG,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19769294/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com