3

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.

2

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 );
}
  • Thanks! What does the , 10, 3 ); numbers do? – Arete Oct 2 '16 at 11:32
  • 1
    Filter priority = 10 (default) and number of input arguments = 3 for the filter callback @Arete – birgire Oct 2 '16 at 11:34
  • For some reason this code is making my featured images (post thumbnails) 80x80px. I realized this just now. But I am not sure why. Can you help me? – Arete Nov 15 '16 at 14:26
  • strange, I don't get that behavior on my vanilla install. Did you modify anything? @Arete – birgire Nov 15 '16 at 15:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.