2013-11-04 26 views
2

有誰知道如何獲得wordpress允許使用SVG文件通過主題customiser面板上傳?Wordpress&SVG

將以下內容添加到主題functions.php文件中,該文件允許上傳SVG(無預覽或特色圖片工作)。

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

但是,這仍然不會讓我上傳或從文件系統中選擇一個SVG或拖放一個。

回答

2

您可以通過將此添加到您當前的主題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後綴

0

使用下面的代碼在WordPress的SVG支持。它將導入和導出.svg媒體文件。

 

    function theme_name_mime_types($mimes) { 
     $mimes['svg'] = 'image/svg+xml'; 
     return $mimes; 
    } 

    add_filter('upload_mimes', 'theme_name_mime_types'); 
    add_filter('mime_types', 'theme_name_mime_types');