I am using
add_theme_support('custom-logo', array(
// The logo will be displayed with the following sizes:
'width' => 200,
'height' => 200,
));
to display a logo image in my sidebar.
in functions.php I have set the size for the large logo:
add_theme_support('custom-logo', array(
// The logo will be displayed with the following sizes:
'width' => 200,
'height' => 200,
));
However, I would also like to use the same logo in the header, but with a size of 80x80px. This means I need to set two different sizes for the_custom_logo
. Is this possible? If so how?
I have tried using add_image_size
but I believe this is wrong so I am not really sure how to do this.
1 Answer
It’s possible to modify the size of the custom logo with:
// Modify the custom logo size
add_filter( 'image_downsize', 'wpse241257_new_custom_logo_size', 10, 3 );
// Display the custom logo
the_custom_logo();
where our filter callback is defined as (PHP 5.4+):
function wpse241257_new_custom_logo_size( $downsize, $id, $size )
{
//-------------------
// Edit to your needs
$size = [80,80]; // Array of width and height
// $size="thumbnail"; // String value of the image size name
//-------------------
remove_filter( current_filter(), __FUNCTION__ ); // Important to avoid recursive loop
return image_downsize( $id, $size );
}