According to the Codex page about adding a Custom Logo, one has to add the following code to functions.php
:
function themename_custom_logo_setup() {
$defaults = array(
'height' => 100,
'width' => 400,
'flex-height' => true,
'flex-width' => true,
'header-text' => array( 'site-title', 'site-description' ),
);
add_theme_support( 'custom-logo', $defaults );
}
add_action( 'after_setup_theme', 'themename_custom_logo_setup' );
I'm not exactly sure about how the array values for height
and width
are used. The documentation says that are "expected sizes", but when I select an image in the customizer to be used a s a logo, it retains the original image size.
How are these values used? Do they define a custom image size name, in the same fashion as the builtin thumbnail
, medium
, large
, and so on?
And if it is so, what name it is, and how can I select it when using the the_custom_logo()
function?
What I'm try to accomplish is to display the custom logo with a maximum image height, let's say 100px
, and to let the width scale proportionally without distorting the picture, even if the size of the image loaded in the customizer is larger.
I'm not really sure on how to do this.
Adding a max-height
CSS value in the stylesheet afterwards is not helping, because the the_custom_logo()
function explicitly sets both height
and width
values inside the <img />
tag.