我正在尝试在WordPress网站的标志中使用SVG文件,如下面的代码所示,我尝试通过调用.svg文件来实现。不幸的是,我无法让它正常工作...
//* Add support for custom header
add_theme_support( 'custom-header', array(
'header_image' => '/images/tgoc.svg',
'header-selector' => '.site-title a',
'header-text' => false,
'height' => 110,
'width' => 320,
) );
我还在functions.php中执行了以下操作:
//* Enable SVG file upload
function custom_mtypes( $m ){
$m['svg'] = 'image/svg+xml';
$m['svgz'] = 'image/svg+xml';
return $m;
}
add_filter( 'upload_mimes', 'custom_mtypes' );
我知道您也可以插入SVG代码,但我的主要问题是在哪里插入此代码?我想尝试并使用Modernizr作为备份。
这是CSS:
/* Logo, hide text */
.header-image .title-area {
padding: 0;
width: 340px;
height: 340px;
background: url(/images/logo.png);
display: block;
}
.no-svg .header-image {
// fallback
background-image: url(/images/logo.png);
}
.header-image .site-title a {
float: left;
min-height: 110px;
width: 100%;
}
function cc_mime_types( $mimes ){ $mimes['svg'] = 'image/svg+xml'; return $mimes; } add_filter( 'upload_mimes', 'cc_mime_types' );
- ctwheels