Twenty Seventeen 使用SVG图像作为 Custom Logo的方法

WordPress 的新主题自定义logo使用SVG格式图像的时候有点问题,首先是强制裁剪SVG,然而并不能成功裁剪。解决方法为修改functions.php

// Add theme support for Custom Logo.
add_theme_support( ‘custom-logo’, array(
‘width’ => 250,
‘height’ => 250,
‘flex-height’ => true,
‘flex-width’ => true,
) );

加上这么一句就能跳过裁剪了。

但是跳过裁剪之后会发现这个logo的尺寸是0x0还是显示不出来。因此还要添加一段额外的CSS

.custom-logo-link img, body.home.title-tagline-hidden.has-header-image .custom-logo-link img,
body.home.title-tagline-hidden.has-header-video .custom-logo-link img {
width: 100%;
height: 100%;
}

我比较懒没有自主题做,你可以把这些东西扔进子主题。不用子主题更新也不会影响logo显示大不了下次换的时候再去functions里加一行就好了。

搞定。

kupbezrecepty.com

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据